add a Select::distinct flag

This commit is contained in:
Tomasz Sowa 2023-02-28 03:37:20 +01:00
parent dee48ea2b5
commit 1821c562f7
Signed by: tomasz.sowa
GPG Key ID: 662CC1438638588B
2 changed files with 16 additions and 4 deletions

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2018-2022, Tomasz Sowa * Copyright (c) 2018-2023, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -170,7 +170,7 @@ public:
if( !select_flags.is_no_auto_generated_columns() ) if( !select_flags.is_no_auto_generated_columns() )
{ {
generate_standard_select(); generate_standard_select(select_flags);
} }
return *this; return *this;
@ -1234,13 +1234,19 @@ protected:
} }
virtual void generate_standard_select() virtual void generate_standard_select(const Select & select_flags)
{ {
if( model_connector && out_stream && db_expression && model.model_env ) if( model_connector && out_stream && db_expression && model.model_env )
{ {
model.model_env->has_autogenerated_select = true; model.model_env->has_autogenerated_select = true;
(*out_stream) << "SELECT "; (*out_stream) << "SELECT ";
if( select_flags.is_distinct() )
{
(*out_stream) << "DISTINCT ";
}
model.generate_select_columns(*out_stream); model.generate_select_columns(*out_stream);
(*out_stream) << " FROM "; (*out_stream) << " FROM ";

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2022, Tomasz Sowa * Copyright (c) 2022-2023, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -50,6 +50,7 @@ public:
default_type = 0, default_type = 0,
no_auto_generated_columns = 1, no_auto_generated_columns = 1,
with_rows_counter = 2, with_rows_counter = 2,
distinct = 4,
}; };
@ -117,6 +118,11 @@ public:
} }
bool is_distinct() const
{
return is_flag_set(distinct);
}
}; };
} }