Commit 828e9209 authored by Murray Cumming's avatar Murray Cumming
Browse files

sql_utils: Put in SqlUtils namespace.

parent a0ae27a6
......@@ -747,10 +747,10 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield
if(!field_name.empty()) //This should not happen.
{
const Gnome::Gda::SqlExpr where_clause =
Utils::build_simple_where_expression(field_in_record.m_table_name,
SqlUtils::build_simple_where_expression(field_in_record.m_table_name,
field_in_record.m_key, field_in_record.m_key_value);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
Utils::build_sql_update_with_where_clause(field_in_record.m_table_name,
SqlUtils::build_sql_update_with_where_clause(field_in_record.m_table_name,
field_in_record.m_field, field_value, where_clause);
try //TODO: The exceptions are probably already handled by query_execute(
......@@ -826,8 +826,8 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const LayoutFieldInRecord
type_vecConstLayoutFields list_fields;
auto layout_item = field_in_record.m_field;
list_fields.emplace_back(layout_item);
auto sql_query = Utils::build_sql_select_with_key(field_in_record.m_table_name,
list_fields, field_in_record.m_key, field_in_record.m_key_value, type_sort_clause(), 1);
auto sql_query = SqlUtils::build_sql_select_with_key(field_in_record.m_table_name,
list_fields, field_in_record.m_key, field_in_record.m_key_value, SqlUtils::type_sort_clause(), 1);
auto data_model = DbUtils::query_execute_select(sql_query);
if(data_model)
......@@ -866,10 +866,10 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const std::shared_ptr<Fie
auto layout_item = std::make_shared<LayoutItem_Field>();
layout_item->set_full_field_details(field);
list_fields.emplace_back(layout_item);
auto sql_query = Utils::build_sql_select_with_where_clause(found_set.m_table_name,
auto sql_query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name,
list_fields,
found_set.m_where_clause,
std::shared_ptr<const Relationship>() /* extra_join */, type_sort_clause(),
std::shared_ptr<const Relationship>() /* extra_join */, SqlUtils::type_sort_clause(),
1 /* limit */);
auto data_model = DbUtils::query_execute_select(sql_query);
......@@ -1190,7 +1190,7 @@ bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gn
cond_id = eq_id;
auto query =
Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsToGet,
SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsToGet,
builder->export_expression(cond_id));
auto data_model = DbUtils::query_execute_select(query);
......@@ -1250,7 +1250,7 @@ void Base_DB::set_found_set_where_clause_for_portal(FoundSet& found_set, const s
if(where_clause_to_key_field)
{
found_set.m_where_clause =
Utils::build_simple_where_expression(where_clause_to_table_name, where_clause_to_key_field, foreign_key_value);
SqlUtils::build_simple_where_expression(where_clause_to_table_name, where_clause_to_key_field, foreign_key_value);
}
}
......
......@@ -494,7 +494,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
if(!fieldsToGet.empty())
{
auto query = Utils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, field_in_record_changed.m_key, field_in_record_changed.m_key_value);
auto query = SqlUtils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, field_in_record_changed.m_key, field_in_record_changed.m_key_value);
//std::cout << "debug: " << G_STRFUNC << ": query=" << query << std::endl;
auto result = DbUtils::query_execute_select(query);
......
......@@ -391,7 +391,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
layout_item_temp->set_full_field_details(field_primary_key);
type_vecLayoutFields layout_fields;
layout_fields.emplace_back(layout_item_temp);
auto sql_query_without_sort = Utils::build_sql_select_with_where_clause(found_set.m_table_name, layout_fields, found_set.m_where_clause, found_set.m_extra_join, type_sort_clause());
auto sql_query_without_sort = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name, layout_fields, found_set.m_where_clause, found_set.m_extra_join, SqlUtils::type_sort_clause());
const Privileges table_privs = Privs::get_current_privs(found_set.m_table_name);
int count = 0;
......@@ -399,7 +399,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
count = DbUtils::count_rows_returned_by(sql_query_without_sort);
if(count < 10000) //Arbitrary large number.
found_set.m_sort_clause.emplace_back( type_pair_sort_field(layout_item_sort, true /* ascending */) );
found_set.m_sort_clause.emplace_back( SqlUtils::type_pair_sort_field(layout_item_sort, true /* ascending */) );
}
}
......@@ -1188,7 +1188,7 @@ void Frame_Glom::on_notebook_find_criteria(const Gnome::Gda::SqlExpr& where_clau
if(!quickfind_criteria.empty())
{
where_clause_to_use =
Utils::get_find_where_clause_quick(get_document(), m_table_name, Gnome::Gda::Value(quickfind_criteria));
SqlUtils::get_find_where_clause_quick(get_document(), m_table_name, Gnome::Gda::Value(quickfind_criteria));
}
//Warn if there was no find criteria:
......
......@@ -134,7 +134,7 @@ public:
/** Do not actually connect to the database,
* but create a Gnome::Gda::Connection object
* just so that utility functions such as Utils::sqlbuilder_get_full_query()
* just so that utility functions such as SqlUtils::sqlbuilder_get_full_query()
* and DbUtils::escape_sql_id() can work.
*/
void set_fake_connection();
......
......@@ -388,7 +388,7 @@ SystemPrefs get_database_preferences(const std::shared_ptr<const Document>& docu
bool succeeded = true;
try
{
//const std::string full_query = Utils::sqlbuilder_get_full_query(builder);
//const std::string full_query = SqlUtils::sqlbuilder_get_full_query(builder);
auto datamodel = query_execute_select(builder);
if(datamodel && (datamodel->get_n_rows() != 0))
{
......@@ -1520,7 +1520,7 @@ static void recalculate_next_auto_increment_value(const Glib::ustring& table_nam
if(Glom::Conversions::value_is_empty(value_max))
{
std::cerr << G_STRFUNC << ": The MAX() value is null for query: " <<
Utils::sqlbuilder_get_full_query(builder) << std::endl;
SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
}
double num_max = Conversions::get_double_for_gda_value_numeric(value_max);
......@@ -1641,13 +1641,13 @@ bool insert_example_data(const std::shared_ptr<const Document>& document, const
//the query, and allow us to set their values.
//std::cout << G_STRFUNC << ": debug: INSERT query: \n"
// << " " << Utils::sqlbuilder_get_full_query(builder) << std::endl;
// << " " << SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
insert_succeeded = query_execute(builder);
if(!insert_succeeded)
{
std::cerr << G_STRFUNC << ": The INSERT query failed: " <<
Utils::sqlbuilder_get_full_query(builder) << std::endl;
SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
break;
}
}
......@@ -1678,7 +1678,7 @@ Glib::RefPtr<Gnome::Gda::DataModel> query_execute_select(const Glib::RefPtr<cons
//Debug output:
if(builder && ConnectionPool::get_instance()->get_show_debug_output())
{
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cout << "debug: " << G_STRFUNC << ": " << full_query << std::endl;
}
......@@ -1720,7 +1720,7 @@ Glib::RefPtr<Gnome::Gda::DataModel> query_execute_select(const Glib::RefPtr<cons
if(!result)
{
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cerr << G_STRFUNC << ": Error while executing SQL: "
<< std::endl << " " << full_query << std::endl << std::endl;
handle_error();
......@@ -1805,7 +1805,7 @@ bool query_execute(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder)
//Debug output:
if(builder && ConnectionPool::get_instance()->get_show_debug_output())
{
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cerr << G_STRFUNC << ": " << full_query << std::endl;
}
......@@ -1818,21 +1818,21 @@ bool query_execute(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder)
catch(const Gnome::Gda::ConnectionError& ex)
{
std::cerr << G_STRFUNC << ": " << ex.what() << std::endl;
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cerr << G_STRFUNC << ": full_query: " << full_query << std::endl;
return false;
}
catch(const Gnome::Gda::ServerProviderError& ex)
{
std::cerr << G_STRFUNC << ": code=" << ex.code() << "message=" << ex.what() << std::endl;
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cerr << G_STRFUNC << ": full_query: " << full_query << std::endl;
return false;
}
catch(const Gnome::Gda::SqlError& ex) //TODO: Make sure that statement_execute_non_select_builder() is documented as throwing this.
{
std::cerr << G_STRFUNC << ": " << ex.what() << std::endl;
const auto full_query = Utils::sqlbuilder_get_full_query(builder);
const auto full_query = SqlUtils::sqlbuilder_get_full_query(builder);
std::cerr << G_STRFUNC << ": full_query: " << full_query << std::endl;
return false;
}
......@@ -1979,7 +1979,7 @@ int count_rows_returned_by(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& sql
}
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
Utils::build_sql_select_count_rows(sql_query);
SqlUtils::build_sql_select_count_rows(sql_query);
int result = 0;
......@@ -2324,7 +2324,7 @@ type_map_fields get_record_field_values(const std::shared_ptr<const Document>& d
{
//sharedptr<const Field> fieldPrimaryKey = get_field_primary_key();
auto query = Utils::build_sql_select_with_key(table_name, fieldsToGet, primary_key, primary_key_value);
auto query = SqlUtils::build_sql_select_with_key(table_name, fieldsToGet, primary_key, primary_key_value);
Glib::RefPtr<const Gnome::Gda::DataModel> data_model;
try
......@@ -2410,7 +2410,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
return result;
}
Utils::type_vecConstLayoutFields fields;
SqlUtils::type_vecConstLayoutFields fields;
fields.emplace_back(layout_choice_first);
if(layout_choice_extra)
......@@ -2438,7 +2438,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
}
//TODO: Support related relationships (in the UI too):
auto builder = Utils::build_sql_select_with_key(
auto builder = SqlUtils::build_sql_select_with_key(
to_table,
fields,
to_field,
......@@ -2463,7 +2463,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
}
const std::string sql_query =
Utils::sqlbuilder_get_full_query(builder);
SqlUtils::sqlbuilder_get_full_query(builder);
//std::cout << "debug: sql_query=" << sql_query << std::endl;
auto datamodel = connection->get_gda_connection()->statement_execute_select(sql_query);
......
......@@ -46,7 +46,7 @@ void export_data_to_vector(const std::shared_ptr<Document>& document, Document::
return;
}
auto query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
auto query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
//TODO: Lock the database (prevent changes) during export.
auto result = DbUtils::query_execute_select(query);
......@@ -96,7 +96,7 @@ void export_data_to_stream(const std::shared_ptr<Document>& document, std::ostre
return;
}
auto query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
auto query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
//TODO: Lock the database (prevent changes) during export.
auto result = DbUtils::query_execute_select(query);
......
......@@ -37,7 +37,7 @@
* - The layout of reports.
*
* libglom also contains utility functions, such as
* Glom::Utils::build_sql_select_with_where_clause(), to build the complicated SQL queries
* Glom::SqlUtils::build_sql_select_with_where_clause(), to build the complicated SQL queries
* used by Glom to retrieve information from the database.
*
* See http://git.gnome.org/browse/glom/tree/glom/libglom/example_document_load.cc
......
......@@ -348,7 +348,7 @@ Privileges Privs::get_table_privileges(const Glib::ustring& group_name, const Gl
args.emplace_back(builder->add_expr("DELETE"));
builder->add_field_value_id(builder->add_function(function_name, args));
//const Glib::ustring sql_debug = Utils::sqlbuilder_get_full_query(builder);
//const Glib::ustring sql_debug = SqlUtils::sqlbuilder_get_full_query(builder);
//std::cout << "DEBUG: " << sql_debug << std::endl;
auto data_model = DbUtils::query_execute_select(builder);
......
......@@ -258,11 +258,11 @@ bool ReportBuilder::report_build_groupby(const FoundSet& found_set_parent, xmlpp
//TODO: Use a SQL parameter instead of using sql().
Gnome::Gda::SqlExpr where_clause =
Utils::build_simple_where_expression(group_field_table_name, field_group_by->get_full_field_details(), group_value);
SqlUtils::build_simple_where_expression(group_field_table_name, field_group_by->get_full_field_details(), group_value);
if(!found_set_parent.m_where_clause.empty())
{
where_clause = Utils::build_combined_where_expression(where_clause, found_set_parent.m_where_clause,
where_clause = SqlUtils::build_combined_where_expression(where_clause, found_set_parent.m_where_clause,
Gnome::Gda::SQL_OPERATOR_TYPE_AND);
}
......@@ -351,7 +351,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
}
//Get list of fields to get from the database.
Utils::type_vecLayoutFields fieldsToGet;
SqlUtils::type_vecLayoutFields fieldsToGet;
for(const auto& layout_item : items)
{
auto layoutitem_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
......@@ -377,7 +377,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
if(one_record_only)
limit = 1;
auto sql_query = Utils::build_sql_select_with_where_clause(found_set.m_table_name,
auto sql_query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name,
fieldsToGet,
found_set.m_where_clause, std::shared_ptr<const Relationship>() /* extra_join */, found_set.m_sort_clause,
limit);
......
......@@ -28,11 +28,10 @@
namespace Glom
{
namespace Utils
namespace SqlUtils
{
template
<typename T_Container>
template<typename T_Container>
auto find_if_uses_relationship_has_relationship(T_Container& container, const std::shared_ptr<const UsesRelationship> uses_relationship_name, bool first_level_only = false) -> decltype(container.begin())
{
const Glib::ustring relationship_name(uses_relationship_name->get_relationship_name());
......@@ -42,7 +41,7 @@ auto find_if_uses_relationship_has_relationship(T_Container& container, const st
if(first_level_only)
related_relationship_name = Glib::ustring();
return find_if(container,
return Utils::find_if(container,
[&relationship_name, &related_relationship_name](const typename T_Container::value_type& element)
{
//Assume that element is a shared_ptr<>.
......@@ -56,7 +55,7 @@ Glib::RefPtr<Gnome::Gda::SqlBuilder> build_sql_select_with_where_clause(const Gl
{
//TODO_Performance:
type_vecConstLayoutFields constFieldsToGet;
copy(fieldsToGet, constFieldsToGet);
Utils::copy(fieldsToGet, constFieldsToGet);
return build_sql_select_with_where_clause(table_name, constFieldsToGet, where_clause, extra_join, sort_clause, limit);
}
......@@ -311,7 +310,7 @@ Glib::RefPtr<Gnome::Gda::SqlBuilder> build_sql_select_with_key(const Glib::ustri
{
//TODO_Performance:
type_vecConstLayoutFields constFieldsToGet;
copy(fieldsToGet, constFieldsToGet);
Utils::copy(fieldsToGet, constFieldsToGet);
return build_sql_select_with_key(table_name, constFieldsToGet, key_field, key_value, sort_clause, limit);
}
......@@ -568,7 +567,7 @@ Glib::RefPtr<Gnome::Gda::SqlBuilder> build_sql_update_with_where_clause(
return builder;
}
} //namespace Utils
} //namespace SqlUtils
} //namespace Glom
......@@ -30,13 +30,13 @@
namespace Glom
{
namespace SqlUtils
{
///field, ascending
typedef std::pair< std::shared_ptr<const LayoutItem_Field>, bool> type_pair_sort_field;
typedef std::vector<type_pair_sort_field> type_sort_clause;
namespace Utils
{
typedef std::vector< std::shared_ptr<const LayoutItem_Field> > type_vecConstLayoutFields;
//typedef Base_DB::type_vecLayoutFields type_vecLayoutFields;
......@@ -125,7 +125,7 @@ Glib::RefPtr<Gnome::Gda::SqlBuilder> build_sql_update_with_where_clause(
std::string sqlbuilder_get_full_query(
const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder);
} //namespace Utils
} //namespace SqlUtils
} //namespace Glom
......
......@@ -204,7 +204,7 @@ bool Box_Data_Calendar_Related::fill_from_database()
}
else
{
where_clause = Utils::build_combined_where_expression(
where_clause = SqlUtils::build_combined_where_expression(
m_found_set.m_where_clause, extra_where_clause,
Gnome::Gda::SQL_OPERATOR_TYPE_AND);
}
......@@ -212,7 +212,7 @@ bool Box_Data_Calendar_Related::fill_from_database()
//Do one SQL query for the whole month and store the cached values here:
clear_cached_database_values();
auto sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause);
auto sql_query = SqlUtils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause);
//std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
auto datamodel = DbUtils::query_execute_select(sql_query);
if(!(datamodel))
......
......@@ -175,7 +175,7 @@ void Box_Data_Details::set_found_set_from_primary_key_value()
if(!Conversions::value_is_empty(m_primary_key_value))
{
m_found_set.m_where_clause = Utils::build_simple_where_expression(
m_found_set.m_where_clause = SqlUtils::build_simple_where_expression(
m_table_name, m_field_primary_key, m_primary_key_value);
//std::cout << "debug: " << G_STRFUNC << ": m_found_set.m_where_clause = " << m_found_set.m_where_clause << std::endl;
}
......@@ -346,7 +346,7 @@ bool Box_Data_Details::fill_from_database()
std::cerr << G_STRFUNC << ": index_primary_key not found and not added. Something went wrong. fieldsToGet.size()=" << fieldsToGet.size() << std::endl;
}
auto query = Utils::build_sql_select_with_key(m_table_name, fieldsToGet, m_field_primary_key, m_primary_key_value);
auto query = SqlUtils::build_sql_select_with_key(m_table_name, fieldsToGet, m_field_primary_key, m_primary_key_value);
Glib::RefPtr<Gnome::Gda::DataModel> result;
if(!primary_key_is_empty)
......
......@@ -289,7 +289,7 @@ void Box_Data_Portal::get_suitable_record_to_view_details(const Gnome::Gda::Valu
auto key_field = get_field_primary_key_for_table(related_table);
//std::cout << "DEBUG: related table=" << related_table << ", whose primary_key=" << key_field->get_name() << ", with value=" << primary_key_value.to_string() << "getting value for: " << layout_item->get_layout_display_name() << std::endl;
auto query = Utils::build_sql_select_with_key(related_table, fieldsToGet, key_field, primary_key_value);
auto query = SqlUtils::build_sql_select_with_key(related_table, fieldsToGet, key_field, primary_key_value);
auto data_model = DbUtils::query_execute_select(query);
......
......@@ -275,7 +275,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const std::shared_ptr<const
{
const auto to_field = document->get_field(to_table, choice_relationship->get_to_field());
found_set.m_where_clause = Utils::build_simple_where_expression(
found_set.m_where_clause = SqlUtils::build_simple_where_expression(
to_table, to_field, foreign_key_value);
}
......
......@@ -111,7 +111,7 @@ void Dialog_ChooseID::on_button_quickfind()
else
{
const Gnome::Gda::SqlExpr where_clause =
Utils::get_find_where_clause_quick(get_document(), m_table_name,
SqlUtils::get_find_where_clause_quick(get_document(), m_table_name,
Gnome::Gda::Value(criteria));
on_box_find_criteria(where_clause);
}
......
......@@ -337,7 +337,7 @@ bool DbTreeModel::refresh_from_database(const FoundSet& found_set)
if(m_connection && !m_found_set.m_table_name.empty() && m_get_records)
{
auto sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_column_fields, m_found_set.m_where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause);
auto sql_query = SqlUtils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_column_fields, m_found_set.m_where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause);
//std::cout << "debug: " << G_STRFUNC << ": " << sql_query << std::endl;
m_gda_datamodel = DbUtils::query_execute_select(sql_query, true /* use_cursor */);
......@@ -348,7 +348,7 @@ bool DbTreeModel::refresh_from_database(const FoundSet& found_set)
m_data_model_columns_count = m_columns_count;
std::cerr << G_STRFUNC << ": error executing SQL. SQL query: \n";
std::cerr << G_STRFUNC << ": " << Utils::sqlbuilder_get_full_query(sql_query) << std::endl;
std::cerr << G_STRFUNC << ": " << SqlUtils::sqlbuilder_get_full_query(sql_query) << std::endl;
ConnectionPool::handle_error_cerr_only();
return false; //No records were found.
}
......@@ -369,7 +369,7 @@ bool DbTreeModel::refresh_from_database(const FoundSet& found_set)
//This doesn't work with cursor-based models: const int count = m_gda_datamodel->get_n_rows();
//because rows count is -1 until we have iterated to the last row.
auto sql_query_without_sort = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_column_fields, m_found_set.m_where_clause, m_found_set.m_extra_join, type_sort_clause());
auto sql_query_without_sort = SqlUtils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_column_fields, m_found_set.m_where_clause, m_found_set.m_extra_join, SqlUtils::type_sort_clause());
const int count = DbUtils::count_rows_returned_by(sql_query_without_sort);
if(count < 0)
{
......
......@@ -261,7 +261,7 @@ FoundSet Notebook_Data::get_found_set_selected() const
auto primary_key_field =
document->get_field_primary_key(m_table_name);
found_set.m_where_clause = Utils::build_simple_where_expression(
found_set.m_where_clause = SqlUtils::build_simple_where_expression(
m_table_name, primary_key_field,
primary_key_value_selected);
return found_set;
......
......@@ -745,7 +745,7 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
type_map_layout_fields_index map_fields_index;
//Get list of fields to get from the database.
Utils::type_vecLayoutFields fieldsToGet;
SqlUtils::type_vecLayoutFields fieldsToGet;
const int count = canvas_group->get_n_children();
guint field_i = 0;
for(int i = 0; i < count; ++i)
......@@ -791,7 +791,7 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
if(fieldsToGet.empty())
return;
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> sql_query = Utils::build_sql_select_with_where_clause(found_set.m_table_name,
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> sql_query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name,
fieldsToGet,
found_set.m_where_clause, std::shared_ptr<const Relationship>() /* extra_join */, found_set.m_sort_clause,
1);
......@@ -907,7 +907,7 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
found_set.m_table_name = portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
set_found_set_where_clause_for_portal(found_set, portal, foreign_key_value);
const Glib::RefPtr<Gnome::Gda::SqlBuilder> sql_query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fields_shown, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
const Glib::RefPtr<Gnome::Gda::SqlBuilder> sql_query = SqlUtils::build_sql_select_with_where_clause(found_set.m_table_name, fields_shown, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
//std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
const auto datamodel = DbUtils::query_execute_select(sql_query);
if(!(datamodel))
......
......@@ -68,9 +68,9 @@ int main()
const Gnome::Gda::Value value("Born To Run");
auto where_field = document->get_field("albums", "name");
const Gnome::Gda::SqlExpr where_clause =
Glom::Utils::build_simple_where_expression("albums", where_field, value);
Glom::SqlUtils::build_simple_where_expression("albums", where_field, value);
Glom::Utils::type_vecLayoutFields fieldsToGet;
Glom::SqlUtils::type_vecLayoutFields fieldsToGet;
auto field = document->get_field("albums", "album_id");
auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
layoutitem->set_full_field_details(field);
......@@ -81,9 +81,9 @@ int main()
fieldsToGet.emplace_back(layoutitem);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
Glom::Utils::build_sql_select_with_where_clause("albums",
Glom::SqlUtils::build_sql_select_with_where_clause("albums",
fieldsToGet, where_clause);
const auto query = Glom::Utils::sqlbuilder_get_full_query(builder);
const auto query = Glom::SqlUtils::sqlbuilder_get_full_query(builder);
g_assert(!query.empty());
if(query.find("album_id") == Glib::ustring::npos)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment