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
This commit is contained in:
2021-05-12 00:27:35 +02:00
parent 009955a0fd
commit c7797ff2f1
5 changed files with 678 additions and 520 deletions

View File

@@ -74,6 +74,20 @@ int BaseExpression::get_work_mode()
PT::TextStream * BaseExpression::get_text_stream()
{
return out_stream;
}
void BaseExpression::set_text_stream(PT::TextStream * out_stream)
{
this->out_stream = out_stream;
}
PT::TextStream * BaseExpression::get_current_stream()
{
return out_stream;
@@ -758,6 +772,186 @@ void BaseExpression::after_field_value_string(FT field_type)
}
void BaseExpression::put_schema_table(const wchar_t * schema_name, const wchar_t * table_name)
{
if( out_stream )
{
before_first_part_long_field_name();
esc(schema_name, *out_stream);
after_first_part_long_field_name();
(*out_stream) << '.';
before_second_part_long_field_name();
esc(table_name, *out_stream);
after_second_part_long_field_name();
}
}
void BaseExpression::put_schema_table(const PT::WTextStream & schema_name, const PT::WTextStream & table_name)
{
if( out_stream )
{
before_first_part_long_field_name();
esc(schema_name, *out_stream);
after_first_part_long_field_name();
(*out_stream) << '.';
before_second_part_long_field_name();
esc(table_name, *out_stream);
after_second_part_long_field_name();
}
}
void BaseExpression::put_table(const wchar_t * table_name)
{
if( out_stream )
{
before_short_field_name();
esc(table_name, *out_stream);
after_short_field_name();
}
}
void BaseExpression::put_table(const PT::WTextStream & table_name)
{
if( out_stream )
{
before_short_field_name();
esc(table_name, *out_stream);
after_short_field_name();
}
}
void BaseExpression::put_table_with_index(const wchar_t * table_name, int index)
{
if( out_stream )
{
before_short_field_name();
esc(table_name, *out_stream);
if( index > 1 )
{
(*out_stream) << index;
}
after_short_field_name();
}
}
void BaseExpression::put_table_with_index(const PT::WTextStream & table_name, int index)
{
if( out_stream )
{
before_short_field_name();
esc(table_name, *out_stream);
if( index > 1 )
{
(*out_stream) << index;
}
after_short_field_name();
}
}
void BaseExpression::put_table_with_index_and_field(const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type)
{
if( out_stream )
{
put_table_with_index(table_name, index);
(*out_stream) << '.';
// IMPROVE ME
// put_field_name seems to be too complicated, it is needed to check there whether field_name is long or short?
put_field_name(field_name, field_type, nullptr);
}
}
void BaseExpression::put_table_with_index_and_field(const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type)
{
if( out_stream )
{
put_table_with_index(table_name, index);
(*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)
{
this->out_stream = &stream;
put_schema_table(schema_name, table_name);
this->out_stream = nullptr;
}
void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const PT::WTextStream & schema_name, const PT::WTextStream & table_name)
{
this->out_stream = &stream;
put_schema_table(schema_name, table_name);
this->out_stream = nullptr;
}
void BaseExpression::table_to_stream(PT::TextStream & stream, const wchar_t * table_name)
{
this->out_stream = &stream;
put_table(table_name);
this->out_stream = nullptr;
}
void BaseExpression::table_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name)
{
this->out_stream = &stream;
put_table(table_name);
this->out_stream = nullptr;
}
void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index)
{
this->out_stream = &stream;
put_table_with_index(table_name, index);
this->out_stream = nullptr;
}
void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index)
{
this->out_stream = &stream;
put_table_with_index(table_name, index);
this->out_stream = nullptr;
}
void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type)
{
this->out_stream = &stream;
put_table_with_index_and_field(table_name, index, field_name, field_type);
this->out_stream = nullptr;
}
void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type)
{
this->out_stream = &stream;
put_table_with_index_and_field(table_name, index, field_name, field_type);
this->out_stream = nullptr;
}
}