From 1821c562f7572475033f086a20695eac8e908799 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 28 Feb 2023 03:37:20 +0100 Subject: [PATCH] add a Select::distinct flag --- src/finder.h | 12 +++++++++--- src/select.h | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/finder.h b/src/finder.h index 624b0fa..d85b737 100644 --- a/src/finder.h +++ b/src/finder.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2018-2022, Tomasz Sowa + * Copyright (c) 2018-2023, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -170,7 +170,7 @@ public: if( !select_flags.is_no_auto_generated_columns() ) { - generate_standard_select(); + generate_standard_select(select_flags); } 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 ) { model.model_env->has_autogenerated_select = true; (*out_stream) << "SELECT "; + + if( select_flags.is_distinct() ) + { + (*out_stream) << "DISTINCT "; + } + model.generate_select_columns(*out_stream); (*out_stream) << " FROM "; diff --git a/src/select.h b/src/select.h index ec8258d..f376c7f 100644 --- a/src/select.h +++ b/src/select.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2022, Tomasz Sowa + * Copyright (c) 2022-2023, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,7 @@ public: default_type = 0, no_auto_generated_columns = 1, with_rows_counter = 2, + distinct = 4, }; @@ -117,6 +118,11 @@ public: } + bool is_distinct() const + { + return is_flag_set(distinct); + } + }; }