add possibility of calculating how many rows there were before LIMIT was applied
The Finder has get_rows_counter() method which returns how many rows there were before LIMIT clause was applied. The select(...) method should be called with Select::with_rows_counter flag in such a case. while here: - change the semantic of Finder, now the select(...) method takes a morm::Select flags, and we have such flags: - Select::no_auto_generated_columns - do not generate columns from models - with_rows_counter - add an additional column for the rows counter - remove Finder::prepare_to_select() - now use select(...) with no_auto_generated_columns flag
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||
* Copyright (c) 2018-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -50,6 +50,10 @@ public:
|
||||
DbExpression();
|
||||
virtual ~DbExpression();
|
||||
|
||||
|
||||
constexpr static const char * COLUMN_ROWS_COUNTER_POSTFIX = "_autoadded_rows_counter";
|
||||
|
||||
|
||||
virtual void set_output_type(int output_type);
|
||||
virtual int get_output_type();
|
||||
|
||||
@@ -68,12 +72,13 @@ public:
|
||||
std::wstring column_expression; // field() methods can be called recursively, so don't make it as class object
|
||||
|
||||
column_expression = new_column_expression;
|
||||
column_expression += L" as ";
|
||||
column_expression += L" AS ";
|
||||
column_expression += new_column_name;
|
||||
|
||||
field(column_expression.c_str(), field_value, field_type, model_env);
|
||||
}
|
||||
|
||||
virtual void generate_rows_counter_column_name(ModelEnv & model_env, pt::TextStream & str);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -97,12 +102,12 @@ protected:
|
||||
void before_field_name();
|
||||
void after_field_name();
|
||||
|
||||
|
||||
private:
|
||||
void add_additional_columns(Model & model);
|
||||
|
||||
void before_field_value_string(const FT & field_type);
|
||||
void after_field_value_string(const FT & field_type);
|
||||
|
||||
virtual void add_rows_counter_column(Model & model);
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user