Commit Graph

23 Commits

Author SHA1 Message Date
Tomasz Sowa bc92654be9 let Finder::page() takes a page number and not an offset 2022-08-04 14:54:04 +02:00
Tomasz Sowa 43dfbd5d5a 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
2022-07-11 17:48:13 +02:00
Tomasz Sowa 3bde64e033 add possibility to set save status for the whole tree
add method:
void Model::set_save_mode2(SaveMode save_mode, bool update_whole_tree = true)
in the future it may be renamed to set_save_mode()
2022-05-12 00:21:42 +02:00
Tomasz Sowa df44296c04 fix: only insert primary keys from the first descendant childs 2022-05-11 23:18:25 +02:00
Tomasz Sowa 34274ca230 namespace PT renamed to pt 2021-05-20 16:25:01 +02:00
Tomasz Sowa 2ad6c8c258 changed the way how to quote schemas, tables and field names,
added escaping table names in insert/update/remove

removed methods from BaseExpression:
virtual void before_short_field_name();
virtual void after_short_field_name();
virtual void before_first_part_long_field_name();
virtual void after_first_part_long_field_name();
virtual void before_second_part_long_field_name();
virtual void after_second_part_long_field_name();

added methods to BaseExpression:
virtual void schema_table_separator();
virtual void table_field_separator();
virtual void before_schema_name();
virtual void after_schema_name();
virtual void before_table_name();
virtual void after_table_name();
virtual void before_field_name();
virtual void after_field_name();
2021-05-13 02:32:03 +02:00
Tomasz Sowa aadc5be350 FT field_type changed to const FT & field_type in functions arguments 2021-05-12 04:53:23 +02:00
Tomasz Sowa 009955a0fd added support for hex strings and binary strings
added FT::hexadecimal, FT::binary and FT::dont_use_utf8
2021-05-11 22:11:31 +02:00
Tomasz Sowa 7bef1d5ead added support for PT::Space as a field in a Model
methods before_field_value_string() and after_field_value_string() moved
from DbExpression and JsonExpression to BaseExpression and made virtual
and now methods before_field_value(const std::wstring &) and after_field_value(const std::wstring &)
(and the rest of them with string arguments) can be removed from DbExpression, PostgreSqlExpression and JsonExpression
2021-03-11 18:40:32 +01:00
Tomasz Sowa f7490594ad 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);
2021-03-11 12:22:37 +01:00
Tomasz Sowa fcf1d28b18 added FT class which is used in Model::field() methods
FT class has following types:
   enum FieldType
   {
	default_type = 0,
        primary_key = 1,
	foreign_key = 2,
	foreign_key_in_child = 4,
	no_insertable = 8,
	no_updatable = 16,
	no_fetchable = 32, /* not supported yet */
   };
an object of FT class are now used in Model::field() methods instead of insertable/updatable/is_primary_key/... boolean flags

changed the semantic of has_foreign_key (which was a bool) flag in child Models:
now on Models and list/vector of Models you should use either FT::foreign_key or FT::foreign_key_in_child
1. FT::foreign_key means that field with this flag is a foreign key and is pointing to the child object
   (it was the case when has_foreign_key was equal to true beforehand)
2. FT::foreign_key_in child means that the foreign key is in the child object and is pointing to the parent object
2021-03-10 16:20:11 +01:00
Tomasz Sowa c18bb48cc8 fixed: incorrect query was created when using neq() method with finder - there was no and or or conjunction 2021-02-23 16:51:43 +01:00
Tomasz Sowa d2f851faf9 now Model.update() and Model.insert() can update/insert the whole tree with child models
(at the moment without lists/vectors only model childs)



git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1205 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-09-04 16:02:18 +00:00
Tomasz Sowa 52422d929e start adding support for inserting child models
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1203 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-08-21 17:42:50 +00:00
Tomasz Sowa 2533b18cfd fixed: in cursor in add_models_to_list(): added_model.model_env should be set after added_model.clear()
fixed: when generating: insert, update or remove statements we have used prefixes for columns
       but the table name was not set in ModelEnv (now we do not use prefixes in such statements)
changed: log_queries field moved from PostgreSQLConnector to DbConnector





git-svn-id: svn://ttmath.org/publicrep/morm/branches/join_models@1195 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-06-17 10:59:39 +00:00
Tomasz Sowa b6fbe29805 added BaseExpression::is_long_field_name()
added BaseExpression::need_to_add_field_prefix()
      now the fields() methods don't take add_column_prefix parameter
      but the field_name (wchar_t*) is tested whether is it a long (with a period) or short name
added BaseExpression::save_foreign_key() (code moved from field())
removed some default method arguments from BaseExpression
added neq() method for Finder
added DbExpression::prepare_short_table_name(const PT::TextStream & table_name, PT::TextStream & short_table_name)




git-svn-id: svn://ttmath.org/publicrep/morm/branches/join_models@1194 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-05-31 18:28:09 +00:00
Tomasz Sowa 9c7a0f3d7e added: support for generating LEFT JOIN statement in Finder
(the primary key should consist of only one column at the moment)



git-svn-id: svn://ttmath.org/publicrep/morm/branches/join_models@1186 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-03-26 18:34:07 +00:00
Tomasz Sowa fd1cc7debe added: Model::ModelData base class to use with Finder, Model.update(), Model.insert() and Model.remove()
added: Model.add_field_for_select() method 




git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1092 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-22 21:04:50 +00:00
Tomasz Sowa 476e5de292 added support for 'in()' statement in 'select'
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1086 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-18 17:52:09 +00:00
Tomasz Sowa 72b2622d08 some work in morm
- support for fetching rows from db
- support for inserting/updating rows



git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1081 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-16 22:46:25 +00:00
Tomasz Sowa 09f31b2803 some work in morm (select statement)
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1079 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-15 23:00:17 +00:00
Tomasz Sowa fceec43d07 some work for SELECT statement
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1077 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-03-30 19:34:45 +00:00
Tomasz Sowa d84ca900c3 reorganizing class hierarchy
git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1075 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-03-23 19:26:57 +00:00