fix: correctly use a table name when using Finder::use_table_prefix(true)

We cannot use aliases in the form of "tablename"."fieldname" - now it was
changed to "tablename.fieldname".

Sample how to get the id field, assuming the table name is 'mymodel'.
mymodel = finder2.
          select(morm::Select::no_auto_generated_columns).
          use_table_prefix(true).
          raw("SELECT id AS \"mymodel.id\"").
          raw("FROM mymodel").
          raw("WHERE id = 25").
          get();

In addition, there was an error that the table name was not correctly set
for the first object in the hierarchy - it was empty, e.g. ""."field_name"
This commit is contained in:
2023-07-15 03:08:02 +02:00
parent e7c62e35dc
commit 6619f3ecb5
7 changed files with 111 additions and 6 deletions

View File

@@ -229,6 +229,7 @@ public:
if( !cursor_helper.has_autogenerated_select && cursor_helper.use_table_prefix_for_fetching_values )
{
result.table();
result.model_env->add_table_name_to_finder_helper();
}
@@ -417,6 +418,7 @@ protected:
if( !cursor_helper.has_autogenerated_select && cursor_helper.use_table_prefix_for_fetching_values )
{
added_model.table();
added_model.model_env->add_table_name_to_finder_helper();
}