winix_fullmorm #4
|
@ -14,10 +14,10 @@ main.o: ../../morm/src/queryresult.h ../../morm/src/flatconnector.h
|
|||
main.o: ../../morm/src/dbexpression.h ../../morm/src/baseexpression.h
|
||||
main.o: ../../morm/src/modelenv.h ../../morm/src/modeldata.h
|
||||
main.o: ../../morm/src/cursorhelper.h ../../morm/src/finderhelper.h
|
||||
main.o: ../../morm/src/fieldvaluehelper.h ../../morm/src/flatexpression.h
|
||||
main.o: ../../morm/src/finder.h ../../pikotools/utf8/utf8.h
|
||||
main.o: ../../morm/src/cursor.h ../../morm/src/jsonexpression.h
|
||||
main.o: ../../morm/src/postgresqlexpression.h ../../morm/src/jsonconnector.h
|
||||
main.o: ../../morm/src/postgresqlconnector.h
|
||||
main.o: ../../morm/src/fieldvaluehelper.h ../../morm/src/ft.h
|
||||
main.o: ../../morm/src/flatexpression.h ../../morm/src/finder.h
|
||||
main.o: ../../pikotools/utf8/utf8.h ../../morm/src/cursor.h
|
||||
main.o: ../../morm/src/jsonexpression.h ../../morm/src/postgresqlexpression.h
|
||||
main.o: ../../morm/src/jsonconnector.h ../../morm/src/postgresqlconnector.h
|
||||
main.o: ../../morm/src/postgresqlqueryresult.h person.h language.h
|
||||
main.o: attachment.h type.h attachment2.h
|
||||
|
|
|
@ -77,14 +77,14 @@ public:
|
|||
|
||||
void map_fields()
|
||||
{
|
||||
field(L"id", id, false, false, true);
|
||||
field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key);
|
||||
field(L"person_id", person_id);
|
||||
field(L"name", name);
|
||||
field(L"content", content);
|
||||
field(L"attachment_id", L"types", types);
|
||||
field(L"attachment_id", L"types", types, FT::foreign_key_in_child);
|
||||
field(L"some_flags", some_flags);
|
||||
field(L"created_date", created_date);
|
||||
field(L"language_id", L"language", language);
|
||||
field(L"language_id", L"language", language, FT::foreign_key);
|
||||
}
|
||||
|
||||
void table_name(PT::TextStream & stream)
|
||||
|
|
|
@ -77,14 +77,14 @@ public:
|
|||
|
||||
void map_fields()
|
||||
{
|
||||
field(L"id", id, false, false, true);
|
||||
field(L"person_id", person_id);
|
||||
field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key);
|
||||
//field(L"person_id", person_id);
|
||||
field(L"name", name);
|
||||
field(L"content", content);
|
||||
field(L"attachment_id", L"types", types);
|
||||
field(L"attachment_id", L"types", types, FT::foreign_key_in_child);
|
||||
field(L"some_flags", some_flags);
|
||||
field(L"created_date", created_date);
|
||||
field(L"language_id", L"language", language);
|
||||
field(L"language_id", L"language", language, FT::foreign_key);
|
||||
}
|
||||
|
||||
void table_name(PT::TextStream & stream)
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
void map_fields()
|
||||
{
|
||||
field(L"id", id, false, false, true);
|
||||
field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key);
|
||||
field(L"english_name", english_name);
|
||||
field(L"local_name", local_name);
|
||||
field(L"code_str", code_str);
|
||||
|
|
|
@ -77,29 +77,23 @@ public:
|
|||
|
||||
void map_fields()
|
||||
{
|
||||
field(L"id", id, false, false, true);
|
||||
field(L"language_id", L"language", language);
|
||||
|
||||
field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key);
|
||||
field(L"language_id", L"language", language, FT::foreign_key);
|
||||
field(L"first_name", first_name);
|
||||
field(L"last_name", last_name);
|
||||
field(L"email", email);
|
||||
|
||||
field(L"person_id", L"attachments", attachments);
|
||||
|
||||
field(L"person_id", L"attachment2", attachment2, true, true, false);
|
||||
|
||||
|
||||
//field(L"id", id, f::no_insertable | f::no_updatable | f::primary_key);
|
||||
//field(L"person_id", attachment, f::insertable | f::updatable | f::foreign_key);
|
||||
//field(L"person_id", attachment, f::insertable, f::updatable, f::foreign_key);
|
||||
field(L"person_id", L"attachments", attachments, FT::foreign_key_in_child);
|
||||
field(L"person_id", L"attachment2", attachment2, FT::foreign_key_in_child | FT::no_insertable | FT::no_updatable);
|
||||
}
|
||||
|
||||
|
||||
void table_name(PT::TextStream & stream)
|
||||
{
|
||||
// schema.table_name or just table_name
|
||||
stream << "public.person";
|
||||
}
|
||||
|
||||
|
||||
void after_select()
|
||||
{
|
||||
if( has_primary_key_set )
|
||||
|
|
|
@ -75,7 +75,7 @@ void make()
|
|||
|
||||
|
||||
morm::Finder<Person> finder(model_connector);
|
||||
Person p = finder.select().where().eq(L"id", 191).get();
|
||||
Person p = finder.select().where().eq(L"id", 207).get();
|
||||
p.to_text(str, true, true);
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
void map_fields()
|
||||
{
|
||||
field(L"id", id, false, false, true);
|
||||
field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key);
|
||||
field(L"attachment_id", attachment_id);
|
||||
field(L"name", name);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ baseexpression.o: ../../pikotools/membuffer/membuffer.h
|
|||
baseexpression.o: ../../pikotools/textstream/types.h morm_types.h modelenv.h
|
||||
baseexpression.o: modeldata.h cursorhelper.h queryresult.h
|
||||
baseexpression.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
baseexpression.o: finderhelper.h fieldvaluehelper.h model.h modelconnector.h
|
||||
baseexpression.o: clearer.h dbconnector.h flatconnector.h dbexpression.h
|
||||
baseexpression.o: flatexpression.h ../../pikotools/utf8/utf8.h
|
||||
baseexpression.o: finderhelper.h fieldvaluehelper.h ft.h model.h
|
||||
baseexpression.o: modelconnector.h clearer.h dbconnector.h flatconnector.h
|
||||
baseexpression.o: dbexpression.h flatexpression.h ../../pikotools/utf8/utf8.h
|
||||
clearer.o: clearer.h ../../pikotools/date/date.h
|
||||
clearer.o: ../../pikotools/convert/inttostr.h model.h
|
||||
clearer.o: ../../pikotools/textstream/textstream.h
|
||||
|
@ -21,7 +21,7 @@ clearer.o: ../../pikotools/textstream/types.h modelconnector.h dbconnector.h
|
|||
clearer.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
clearer.o: queryresult.h flatconnector.h dbexpression.h baseexpression.h
|
||||
clearer.o: morm_types.h modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
||||
clearer.o: fieldvaluehelper.h flatexpression.h
|
||||
clearer.o: fieldvaluehelper.h ft.h flatexpression.h
|
||||
dbconnector.o: dbconnector.h ../../pikotools/textstream/textstream.h
|
||||
dbconnector.o: ../../pikotools/space/space.h
|
||||
dbconnector.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
|
||||
|
@ -30,7 +30,7 @@ dbconnector.o: ../../pikotools/membuffer/membuffer.h
|
|||
dbconnector.o: ../../pikotools/textstream/types.h ../../pikotools/log/log.h
|
||||
dbconnector.o: ../../pikotools/log/filelog.h queryresult.h dbexpression.h
|
||||
dbconnector.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||
dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h model.h
|
||||
dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h ft.h model.h
|
||||
dbconnector.o: modelconnector.h clearer.h flatconnector.h flatexpression.h
|
||||
dbconnector.o: ../../pikotools/utf8/utf8.h ../../pikotools/convert/convert.h
|
||||
dbconnector.o: ../../pikotools/convert/inttostr.h
|
||||
|
@ -47,7 +47,7 @@ dbexpression.o: ../../pikotools/membuffer/membuffer.h
|
|||
dbexpression.o: ../../pikotools/textstream/types.h morm_types.h modelenv.h
|
||||
dbexpression.o: modeldata.h cursorhelper.h queryresult.h
|
||||
dbexpression.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
dbexpression.o: finderhelper.h fieldvaluehelper.h
|
||||
dbexpression.o: finderhelper.h fieldvaluehelper.h ft.h
|
||||
flatconnector.o: flatconnector.h ../../pikotools/textstream/textstream.h
|
||||
flatconnector.o: ../../pikotools/space/space.h
|
||||
flatconnector.o: ../../pikotools/textstream/types.h
|
||||
|
@ -58,7 +58,7 @@ flatconnector.o: ../../pikotools/textstream/types.h flatexpression.h
|
|||
flatconnector.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||
flatconnector.o: cursorhelper.h queryresult.h ../../pikotools/log/log.h
|
||||
flatconnector.o: ../../pikotools/log/filelog.h finderhelper.h
|
||||
flatconnector.o: fieldvaluehelper.h model.h modelconnector.h clearer.h
|
||||
flatconnector.o: fieldvaluehelper.h ft.h model.h modelconnector.h clearer.h
|
||||
flatconnector.o: dbconnector.h dbexpression.h
|
||||
flatexpression.o: flatexpression.h baseexpression.h
|
||||
flatexpression.o: ../../pikotools/textstream/textstream.h
|
||||
|
@ -70,7 +70,7 @@ flatexpression.o: ../../pikotools/membuffer/membuffer.h
|
|||
flatexpression.o: ../../pikotools/textstream/types.h morm_types.h modelenv.h
|
||||
flatexpression.o: modeldata.h cursorhelper.h queryresult.h
|
||||
flatexpression.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
flatexpression.o: finderhelper.h fieldvaluehelper.h
|
||||
flatexpression.o: finderhelper.h fieldvaluehelper.h ft.h
|
||||
jsonconnector.o: jsonconnector.h flatconnector.h
|
||||
jsonconnector.o: ../../pikotools/textstream/textstream.h
|
||||
jsonconnector.o: ../../pikotools/space/space.h
|
||||
|
@ -82,7 +82,7 @@ jsonconnector.o: ../../pikotools/textstream/types.h jsonexpression.h
|
|||
jsonconnector.o: flatexpression.h baseexpression.h morm_types.h modelenv.h
|
||||
jsonconnector.o: modeldata.h cursorhelper.h queryresult.h
|
||||
jsonconnector.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
jsonconnector.o: finderhelper.h fieldvaluehelper.h
|
||||
jsonconnector.o: finderhelper.h fieldvaluehelper.h ft.h
|
||||
jsonexpression.o: jsonexpression.h flatexpression.h baseexpression.h
|
||||
jsonexpression.o: ../../pikotools/textstream/textstream.h
|
||||
jsonexpression.o: ../../pikotools/space/space.h
|
||||
|
@ -93,7 +93,7 @@ jsonexpression.o: ../../pikotools/membuffer/membuffer.h
|
|||
jsonexpression.o: ../../pikotools/textstream/types.h morm_types.h modelenv.h
|
||||
jsonexpression.o: modeldata.h cursorhelper.h queryresult.h
|
||||
jsonexpression.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h
|
||||
jsonexpression.o: finderhelper.h fieldvaluehelper.h
|
||||
jsonexpression.o: finderhelper.h fieldvaluehelper.h ft.h
|
||||
model.o: model.h ../../pikotools/textstream/textstream.h
|
||||
model.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
model.o: ../../pikotools/date/date.h ../../pikotools/convert/inttostr.h
|
||||
|
@ -102,7 +102,8 @@ model.o: ../../pikotools/textstream/types.h modelconnector.h clearer.h
|
|||
model.o: dbconnector.h ../../pikotools/log/log.h
|
||||
model.o: ../../pikotools/log/filelog.h queryresult.h flatconnector.h
|
||||
model.o: dbexpression.h baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||
model.o: cursorhelper.h finderhelper.h fieldvaluehelper.h flatexpression.h
|
||||
model.o: cursorhelper.h finderhelper.h fieldvaluehelper.h ft.h
|
||||
model.o: flatexpression.h
|
||||
modelconnector.o: modelconnector.h clearer.h ../../pikotools/date/date.h
|
||||
modelconnector.o: ../../pikotools/convert/inttostr.h dbconnector.h
|
||||
modelconnector.o: ../../pikotools/textstream/textstream.h
|
||||
|
@ -125,7 +126,7 @@ postgresqlconnector.o: ../../pikotools/log/filelog.h queryresult.h
|
|||
postgresqlconnector.o: postgresqlqueryresult.h ../../pikotools/utf8/utf8.h
|
||||
postgresqlconnector.o: postgresqlexpression.h dbexpression.h baseexpression.h
|
||||
postgresqlconnector.o: morm_types.h modelenv.h modeldata.h cursorhelper.h
|
||||
postgresqlconnector.o: finderhelper.h fieldvaluehelper.h
|
||||
postgresqlconnector.o: finderhelper.h fieldvaluehelper.h ft.h
|
||||
postgresqlconnector.o: ../../pikotools/convert/strtoint.h
|
||||
postgresqlconnector.o: ../../pikotools/convert/text.h
|
||||
postgresqlconnector.o: ../../pikotools/convert/misc.h
|
||||
|
@ -141,7 +142,7 @@ postgresqlexpression.o: ../../pikotools/textstream/types.h morm_types.h
|
|||
postgresqlexpression.o: modelenv.h modeldata.h cursorhelper.h queryresult.h
|
||||
postgresqlexpression.o: ../../pikotools/log/log.h
|
||||
postgresqlexpression.o: ../../pikotools/log/filelog.h finderhelper.h
|
||||
postgresqlexpression.o: fieldvaluehelper.h
|
||||
postgresqlexpression.o: fieldvaluehelper.h ft.h
|
||||
postgresqlqueryresult.o: postgresqlqueryresult.h queryresult.h
|
||||
postgresqlqueryresult.o: ../../pikotools/log/log.h
|
||||
postgresqlqueryresult.o: ../../pikotools/textstream/textstream.h
|
||||
|
|
|
@ -117,8 +117,8 @@ void BaseExpression::dump_additional_info(Model & model)
|
|||
{
|
||||
if( model.model_env && model.model_env->dump_mode )
|
||||
{
|
||||
field(L"model_save_mode", model.save_mode, false, false, false, model.model_env);
|
||||
field(L"has_primary_key_set", model.has_primary_key_set, false, false, false, model.model_env);
|
||||
field(L"model_save_mode", model.save_mode, FT::no_insertable | FT::no_updatable | FT::no_fetchable, model.model_env);
|
||||
field(L"has_primary_key_set", model.has_primary_key_set, FT::no_insertable | FT::no_updatable | FT::no_fetchable, model.model_env);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ void BaseExpression::after_generate_from_model()
|
|||
}
|
||||
|
||||
|
||||
bool BaseExpression::can_field_be_generated(bool insertable, bool updatable, bool is_primary_key)
|
||||
bool BaseExpression::can_field_be_generated(FT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "date/date.h"
|
||||
#include "morm_types.h"
|
||||
#include "modelenv.h"
|
||||
|
||||
#include "ft.h"
|
||||
|
||||
|
||||
namespace morm
|
||||
|
@ -73,9 +73,9 @@ public:
|
|||
|
||||
|
||||
template<typename FieldValue>
|
||||
void field(const wchar_t * field_name, const FieldValue & field_value, bool insertable, bool updatable, bool is_primary_key, ModelEnv * model_env)
|
||||
void field(const wchar_t * field_name, const FieldValue & field_value, FT field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(insertable, updatable, is_primary_key) )
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
{
|
||||
field_before();
|
||||
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
|
||||
{
|
||||
put_field_value_or_null(field_value, is_primary_key, model_env);
|
||||
put_field_value_or_null(field_value, field_type, model_env);
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
{
|
||||
put_field_name((*model_env->set_field_name_helper)[model_env->field_index], model_env);
|
||||
put_name_value_separator();
|
||||
put_field_value_or_null(field_value, is_primary_key, model_env);
|
||||
put_field_value_or_null(field_value, field_type, model_env);
|
||||
}
|
||||
|
||||
model_env->field_index += 1;
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
{
|
||||
put_field_name(field_name, model_env);
|
||||
put_name_value_separator();
|
||||
put_field_value_or_null(field_value, is_primary_key, model_env);
|
||||
put_field_value_or_null(field_value, field_type, model_env);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,9 +122,9 @@ public:
|
|||
|
||||
|
||||
template<typename FieldValue>
|
||||
void put_field_value_or_null(const FieldValue & field_value, bool is_primary_key, ModelEnv * model_env)
|
||||
void put_field_value_or_null(const FieldValue & field_value, FT field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( is_primary_key )
|
||||
if( field_type.is_primary_key() )
|
||||
{
|
||||
if( model_env && model_env->has_primary_key_set )
|
||||
put_field_value(field_value);
|
||||
|
@ -159,10 +159,9 @@ public:
|
|||
|
||||
|
||||
template<typename ModelContainer>
|
||||
void field_list(const wchar_t * field_name, ModelContainer & field_value, bool insertable, bool updatable, bool is_primary_key,
|
||||
ModelConnector * model_connector, ModelEnv * model_env)
|
||||
void field_list(const wchar_t * field_name, ModelContainer & field_value, FT field_type, ModelConnector * model_connector, ModelEnv * model_env)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(insertable, updatable, is_primary_key) )
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
{
|
||||
field_before();
|
||||
|
||||
|
@ -183,9 +182,9 @@ public:
|
|||
}
|
||||
|
||||
template<typename ModelClass>
|
||||
void field_model(const wchar_t * field_name, ModelClass & field_model, bool insertable, bool updatable, bool is_primary_key, ModelEnv * model_env)
|
||||
void field_model(const wchar_t * field_name, ModelClass & field_model, FT field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(insertable, updatable, is_primary_key) )
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
{
|
||||
field_before();
|
||||
|
||||
|
@ -211,11 +210,10 @@ public:
|
|||
}
|
||||
|
||||
template<typename FieldValue>
|
||||
void field_to_stream(PT::TextStream & stream, const wchar_t * field_name, const FieldValue & field_value, bool insertable, bool updatable, bool is_primary_key,
|
||||
ModelEnv * model_env)
|
||||
void field_to_stream(PT::TextStream & stream, const wchar_t * field_name, const FieldValue & field_value, FT field_type, ModelEnv * model_env)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
field(field_name, field_value, insertable, updatable, is_primary_key, model_env);
|
||||
field(field_name, field_value, field_type, model_env);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
@ -274,12 +272,10 @@ protected:
|
|||
|
||||
virtual void before_generate_from_model();
|
||||
virtual void after_generate_from_model();
|
||||
virtual bool can_field_be_generated(bool insertable, bool updatable, bool is_primary_key);
|
||||
virtual bool can_field_be_generated(FT);
|
||||
virtual void field_before();
|
||||
virtual void field_after();
|
||||
|
||||
//void field(const wchar_t * field_name, Model & field, bool insertable = true, bool updatable = true);
|
||||
|
||||
virtual void put_field_name(const wchar_t * field_name, ModelEnv * model_env);
|
||||
|
||||
virtual void save_foreign_key(const wchar_t * field_name, ModelEnv * model_env);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018, Tomasz Sowa
|
||||
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -86,7 +86,7 @@ protected:
|
|||
std::vector<int> conjunctions;
|
||||
|
||||
|
||||
bool can_field_be_generated(bool insertable, bool updatable, bool is_primary_key);
|
||||
bool can_field_be_generated(FT field_type);
|
||||
|
||||
void field_before();
|
||||
|
||||
|
|
12
src/finder.h
12
src/finder.h
|
@ -333,7 +333,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_EQ);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -346,7 +346,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_NOT_EQ);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -358,7 +358,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_LT);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -371,7 +371,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_GT);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -384,7 +384,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_LE);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -397,7 +397,7 @@ public:
|
|||
if( db_expression )
|
||||
{
|
||||
db_expression->set_output_type(MORM_OUTPUT_TYPE_WHERE_GE);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, false, false, false, &model_env);
|
||||
db_expression->field_to_stream(*out_stream, field_name, field_value, FT::default_type, &model_env);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* This file is a part of morm
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_morm_ft
|
||||
#define headerfile_morm_ft
|
||||
|
||||
namespace morm
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* field types
|
||||
*/
|
||||
class FT
|
||||
{
|
||||
public:
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
/*
|
||||
* type can be a superposition from FieldType values
|
||||
*/
|
||||
int type;
|
||||
|
||||
|
||||
|
||||
FT()
|
||||
{
|
||||
type = 0;
|
||||
}
|
||||
|
||||
FT(const FT & field_type)
|
||||
{
|
||||
type = field_type.type;
|
||||
}
|
||||
|
||||
FT(FieldType type)
|
||||
{
|
||||
this->type = static_cast<int>(type);
|
||||
}
|
||||
|
||||
FT(int type)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
FT & operator=(const FT & field_type)
|
||||
{
|
||||
type = field_type.type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_flag_set(int flag_mask) const
|
||||
{
|
||||
return (type & flag_mask) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool is_primary_key() const
|
||||
{
|
||||
return is_flag_set(primary_key);
|
||||
}
|
||||
|
||||
|
||||
bool is_foreign_key() const
|
||||
{
|
||||
return is_flag_set(foreign_key);
|
||||
}
|
||||
|
||||
bool is_foreign_key_in_child() const
|
||||
{
|
||||
return is_flag_set(foreign_key_in_child);
|
||||
}
|
||||
|
||||
bool is_insertable() const
|
||||
{
|
||||
return !is_flag_set(no_insertable);
|
||||
}
|
||||
|
||||
|
||||
bool is_updatable() const
|
||||
{
|
||||
return !is_flag_set(no_updatable);
|
||||
}
|
||||
|
||||
|
||||
bool is_fetchable() const
|
||||
{
|
||||
return !is_flag_set(no_fetchable);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -943,5 +943,25 @@ void Model::put_fields_to_log(PT::Log & log, const wchar_t * db_field_name, cons
|
|||
}
|
||||
|
||||
|
||||
PT::TextStream Model::log_table_name()
|
||||
{
|
||||
PT::TextStream buf;
|
||||
table_name(buf);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
PT::TextStream Model::log_table_name(const wchar_t * db_field_name)
|
||||
{
|
||||
PT::TextStream buf;
|
||||
table_name(buf);
|
||||
buf << '.' << db_field_name;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
661
src/model.h
661
src/model.h
File diff suppressed because it is too large
Load Diff
|
@ -46,6 +46,8 @@ namespace morm
|
|||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class ModelEnv
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue