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

@@ -1261,7 +1261,7 @@ void Model::field_model_left_join(const wchar_t * db_field_name, Model & field_m
db_expression->schema_table_to_stream(join_tables_str, field_model.model_env->schema_name, field_model.model_env->table_name);
join_tables_str << " AS ";
db_expression->table_with_index_to_stream(join_tables_str, field_model.model_env->table_name, field_model.model_env->table_index);
db_expression->alias_to_stream(join_tables_str, field_model.model_env->table_name, field_model.model_env->table_index);
db_expression->set_work_mode(MORM_WORK_MODE_MODEL_SAVE_FIELDS);
db_expression->set_output_type(MORM_OUTPUT_TYPE_JOIN_TABLES);