winix_fullmorm #4

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

merge winix_fullmorm branch:

  • changed the way home table names are set
  • field() methods now takes FT field parameters (instead of booleans)
  • field method don't make a test for 'long format' now
  • fixes in escaping table names in Finder
  • added basic support for making migrations
  • has_primary_key flag in Model (I am not sure if this will be changed)
merge winix_fullmorm branch: - changed the way home table names are set - field() methods now takes FT field parameters (instead of booleans) - field method don't make a test for 'long format' now - fixes in escaping table names in Finder - added basic support for making migrations - has_primary_key flag in Model (I am not sure if this will be changed)
tomasz.sowa added 27 commits 2021-05-27 10:49:35 +02:00
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)
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
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);
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
fixed: Finder didn't use full table name (schema.table) in "from" clause
in BaseExpression::put_field_value_list(): has_primary_key_set flag was not copied to model_env
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
WIP: #2
added FT::hexadecimal, FT::binary and FT::dont_use_utf8
some methods moved from model.h to model.cpp and from baseexpression.h to baseexpression.cpp
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)
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();
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()
added: field type: no_removable - it is used only with child Models objects
and this prevented to insert a model which had a primary key set by hand
tomasz.sowa merged commit 284cbc5c66 into master 2021-05-27 10:49:46 +02:00
Sign in to join this conversation.
No description provided.