winix_fullmorm #4

Merged
tomasz.sowa merged 27 commits from winix_fullmorm into master 2021-05-27 10:49:46 +02:00

27 Commits

Author SHA1 Message Date
Tomasz Sowa 2f72bd29ec fixed: has_primary_key_set was always set to false in Model::insert()
and this prevented to insert a model which had a primary key set by hand
2021-05-21 22:36:04 +02:00
Tomasz Sowa e0e3465673 fixed: such field types: no_insertable, no_updatable were not taken into account on Model child objects
added: field type: no_removable - it is used only with child Models objects
2021-05-21 22:12:10 +02:00
Tomasz Sowa fcd2c4775b updated to the new pikotools api: snake_case names of methods from SpaceParser 2021-05-21 04:51:12 +02:00
Tomasz Sowa 9598cc4def updated to the new pikotools api: SpaceParser::SetSpace(...) methods have been removed 2021-05-21 01:35:16 +02:00
Tomasz Sowa 0ff900f626 updated to the new pikotools api: changed utf8 functions PascalCase to snake_case 2021-05-21 00:32:29 +02:00
Tomasz Sowa 34274ca230 namespace PT renamed to pt 2021-05-20 16:25:01 +02:00
Tomasz Sowa b12037a7e5 added basic support for making migrations 2021-05-14 03:24:53 +02:00
Tomasz Sowa de4abeb91c added to Finder: methods eq() and similar with table_name as an argument
Finder<ModelClass> & eq(const wchar_t * table_name, const wchar_t * field_name, const FieldValue & field_value)
Finder<ModelClass> & eq(const wchar_t * table_name, int table_index, const wchar_t * field_name, const FieldValue & field_value)
and similar for neq(), lt(), gt(), le(), ge() and in()
2021-05-13 19:32:31 +02:00
Tomasz Sowa 6eaa9088e5 renamed in Model: map_fields() to fields(), prepare_table() to table() 2021-05-13 03:27:21 +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 a1537cf8d5 BaseExpression: removed methods: put_long_field_name() and put_short_field_name()
now method put_field_name() is not making a test whether field_name is in long format
and only puts the field name (without table name),
this allows us to have a dot in the column name (field_name)
2021-05-13 00:19:22 +02:00
Tomasz Sowa 179be2864f change FT field_type in PostgreSQLConnector 2021-05-12 05:39:31 +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 c7797ff2f1 fixed #2: escape tables/columns names in Finder left join queries
some methods moved from model.h to model.cpp and from baseexpression.h to baseexpression.cpp
2021-05-12 00:27:35 +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 2afe111c57 escape table names in Finder (select sql statement)
WIP: #2
2021-04-30 01:23:22 +02:00
Tomasz Sowa c87afb40d2 use prepare_table() only with a database and not for flat strings
Model::prepare_table() will create a log: "you should provide the table name...."
and it is not needed if a Model object is used only for flat strings
2021-04-14 17:46:19 +02:00
Tomasz Sowa 1c5d32551a fixed: a null was printed for id when serializing lists/vectors
in BaseExpression::put_field_value_list(): has_primary_key_set flag was not copied to model_env
2021-04-14 16:21:10 +02:00
Tomasz Sowa 9a4fd9b050 fixed: add_field_for_select from Model incorrectly escaped a field string (column name)
fixed: Finder didn't use full table name (schema.table) in "from" clause
2021-04-12 18:53:55 +02:00
Tomasz Sowa 79fd642ef7 make depend 2021-04-09 17:50:23 +02:00
Tomasz Sowa c85165b442 updated to the new api of Space from pikotools 2021-04-08 17:21:12 +02:00
Tomasz Sowa d78aa325d3 fixed: prepare_to_select() should initialize 'model' but it was initialized only in select() 2021-04-08 17:19:52 +02:00
Tomasz Sowa 1e2cbad6a7 make depend 2021-04-08 17:18:48 +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 133a45c84b Added flag has_primary_key_set to Model
Now we know whether the primary key is defined or not
and we do not allow to make update/remove if the key is not defined.

And when doing insert/update we can put NULL if child models don't have
the primary key set (fields with has_foreign_key set to true).

Now in after_select() we should also set has_primary_key_set flag
or just call get_last_sequence_for_primary_key instead of get_last_sequence.

fixed: added prefix +00 when serializing PT::Date to PostgreSQL (time zone)
(for a column with a time zone there was a wrong value saved)
2021-03-09 18:10:34 +01:00