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)
This commit is contained in:
@@ -169,44 +169,20 @@ void BaseExpression::field_after()
|
||||
}
|
||||
|
||||
|
||||
bool BaseExpression::is_long_field_name(const wchar_t * field_name)
|
||||
|
||||
void BaseExpression::put_field_name_and_table_if_needed(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
bool is_long = false;
|
||||
|
||||
while( *field_name != 0 )
|
||||
if( use_prefix && model_env )
|
||||
{
|
||||
if( *field_name == '.' )
|
||||
{
|
||||
is_long = true;
|
||||
break;
|
||||
}
|
||||
|
||||
field_name += 1;
|
||||
put_table_with_index_and_field(model_env->table_name, model_env->table_index, field_name, field_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
put_field_name(field_name, field_type, model_env);
|
||||
}
|
||||
|
||||
return is_long;
|
||||
}
|
||||
|
||||
|
||||
bool BaseExpression::is_long_field_name(const PT::TextStream & field_name)
|
||||
{
|
||||
PT::TextStream::const_iterator i = field_name.begin();
|
||||
bool is_long = false;
|
||||
|
||||
while( i != field_name.end() )
|
||||
{
|
||||
if( *i == '.' )
|
||||
{
|
||||
is_long = true;
|
||||
break;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
return is_long;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
@@ -216,73 +192,15 @@ void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field
|
||||
}
|
||||
else
|
||||
{
|
||||
if( is_long_field_name(field_name) )
|
||||
put_long_field_name(field_name);
|
||||
else
|
||||
put_short_field_name(field_name, model_env);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const wchar_t * BaseExpression::put_long_part_field_name(const wchar_t * field_name)
|
||||
{
|
||||
while( *field_name != 0 && *field_name != '.' )
|
||||
{
|
||||
esc(*field_name, *out_stream);
|
||||
field_name += 1;
|
||||
}
|
||||
|
||||
return field_name;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_long_field_name(const wchar_t * field_name)
|
||||
{
|
||||
before_first_part_long_field_name();
|
||||
field_name = put_long_part_field_name(field_name);
|
||||
after_first_part_long_field_name();
|
||||
|
||||
if( *field_name == '.' )
|
||||
{
|
||||
field_name += 1;
|
||||
(*out_stream) << '.';
|
||||
|
||||
before_second_part_long_field_name();
|
||||
field_name = put_long_part_field_name(field_name);
|
||||
after_second_part_long_field_name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_short_field_name(const wchar_t * field_name, ModelEnv * model_env)
|
||||
{
|
||||
if( use_prefix && model_env )
|
||||
{
|
||||
before_first_part_long_field_name();
|
||||
esc(model_env->table_name, *out_stream);
|
||||
|
||||
if( model_env->table_index > 1 )
|
||||
{
|
||||
(*out_stream) << model_env->table_index;
|
||||
}
|
||||
|
||||
after_first_part_long_field_name();
|
||||
|
||||
(*out_stream) << '.';
|
||||
|
||||
before_second_part_long_field_name();
|
||||
esc(field_name, *out_stream);
|
||||
after_second_part_long_field_name();
|
||||
}
|
||||
else
|
||||
{
|
||||
// !!!!!!!!!!!!!!!!!!!
|
||||
// there are too many methods: before... after...
|
||||
before_short_field_name();
|
||||
esc(field_name, *out_stream);
|
||||
after_short_field_name();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
PT::TextStream str;
|
||||
@@ -886,6 +804,26 @@ void BaseExpression::put_table_with_index_and_field(const PT::WTextStream & tabl
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_table_and_field(const wchar_t * table_name, const wchar_t * field_name, const FT & field_type)
|
||||
{
|
||||
if( out_stream )
|
||||
{
|
||||
put_table(table_name);
|
||||
(*out_stream) << '.';
|
||||
put_field_name(field_name, field_type, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseExpression::put_table_and_field(const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type)
|
||||
{
|
||||
if( out_stream )
|
||||
{
|
||||
put_table(table_name);
|
||||
(*out_stream) << '.';
|
||||
put_field_name(field_name, field_type, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name)
|
||||
@@ -952,6 +890,22 @@ void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & strea
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_table_and_field(table_name, field_name, field_type);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_table_and_field(table_name, field_name, field_type);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user