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
This commit is contained in:
@@ -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
|
||||
@@ -62,23 +62,23 @@ int DbExpression::get_output_type()
|
||||
}
|
||||
|
||||
|
||||
bool DbExpression::can_field_be_generated(bool insertable, bool updatable, bool is_primary_key)
|
||||
bool DbExpression::can_field_be_generated(FT field_type)
|
||||
{
|
||||
if( output_type == MORM_OUTPUT_TYPE_DB_INSERT )
|
||||
{
|
||||
return insertable;
|
||||
return field_type.is_insertable();
|
||||
}
|
||||
else
|
||||
if( output_type == MORM_OUTPUT_TYPE_DB_UPDATE )
|
||||
{
|
||||
return updatable;
|
||||
return field_type.is_updatable();
|
||||
}
|
||||
else
|
||||
if( output_type == MORM_OUTPUT_TYPE_DB_PRIMARY_KEY ||
|
||||
output_type == MORM_OUTPUT_TYPE_JOIN_TABLES ||
|
||||
output_type == MORM_OUTPUT_TYPE_DB_INSERT_PRIMARY_KEY )
|
||||
{
|
||||
return is_primary_key;
|
||||
return field_type.is_primary_key();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user