changed the way how the table name is set in a Model - added prepare_table() method

removed from Model:
virtual void table_name(PT::TextStream & stream);

added to Model:
virtual void prepare_table();
virtual void table(const wchar_t * table_name);
virtual void table(const wchar_t * schema_name, const wchar_t * table_name);
This commit is contained in:
2021-03-11 12:22:37 +01:00
parent fcf1d28b18
commit f7490594ad
18 changed files with 193 additions and 182 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2019, Tomasz Sowa
* Copyright (c) 2018-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -182,8 +182,8 @@ void DbConnector::generate_insert_query(PT::TextStream & stream, Model & model)
db_expression->clear();
db_expression->allow_to_use_prefix(false);
stream << "insert into ";
model.table_name(stream);
// IMPROVEME escape table_name
stream << "insert into " << model.get_table_name();
stream << " (";
db_expression->set_work_mode(MORM_WORK_MODE_MODEL_FIELDS);
@@ -207,8 +207,8 @@ void DbConnector::generate_update_query(PT::TextStream & stream, Model & model)
db_expression->clear();
db_expression->allow_to_use_prefix(false);
stream << "update ";
model.table_name(stream);
// IMPROVEME escape table_name
stream << "update " << model.get_table_name();
stream << " set ";
db_expression->set_work_mode(MORM_WORK_MODE_MODEL_FIELDS_VALUES);
@@ -232,8 +232,9 @@ void DbConnector::generate_remove_query(PT::TextStream & stream, Model & model)
db_expression->clear();
db_expression->allow_to_use_prefix(false);
stream << "delete from ";
model.table_name(stream);
// IMPROVEME escape table_name
stream << "delete from " << model.get_table_name();
stream << " where ";
db_expression->set_work_mode(MORM_WORK_MODE_MODEL_FIELDS_VALUES);
db_expression->set_output_type(MORM_OUTPUT_TYPE_DB_PRIMARY_KEY);