[glom] sql_utils: Put in SqlUtils namespace.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] sql_utils: Put in SqlUtils namespace.
- Date: Thu, 17 Mar 2016 14:22:53 +0000 (UTC)
commit 828e9209af42ef801027ef21d8d7e9d353b81dbe
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Mar 17 14:06:34 2016 +0100
sql_utils: Put in SqlUtils namespace.
glom/base_db.cc | 16 +++++-----
glom/base_db_table_data.cc | 2 +-
glom/frame_glom.cc | 6 ++--
glom/libglom/connectionpool.h | 2 +-
glom/libglom/db_utils.cc | 30 ++++++++++----------
glom/libglom/db_utils_export.cc | 4 +-
glom/libglom/init.h | 2 +-
glom/libglom/privs.cc | 2 +-
glom/libglom/report_builder.cc | 8 ++--
glom/libglom/sql_utils.cc | 13 ++++----
glom/libglom/sql_utils.h | 8 ++--
glom/mode_data/box_data_calendar_related.cc | 4 +-
glom/mode_data/box_data_details.cc | 4 +-
glom/mode_data/box_data_portal.cc | 2 +-
.../datawidget/combochoiceswithtreemodel.cc | 2 +-
glom/mode_data/datawidget/dialog_choose_id.cc | 2 +-
glom/mode_data/datawidget/treemodel_db.cc | 6 ++--
glom/mode_data/notebook_data.cc | 2 +-
glom/print_layout/canvas_print_layout.cc | 6 ++--
tests/test_fake_connection.cc | 8 ++--
tests/test_selfhosting_new_from_example_float.cc | 8 ++--
tests/test_selfhosting_new_then_image.cc | 8 ++--
tests/test_selfhosting_sqlinjection.cc | 24 ++++++++--------
tests/test_selfhosting_utils.cc | 18 ++++++------
24 files changed, 93 insertions(+), 94 deletions(-)
---
diff --git a/glom/base_db.cc b/glom/base_db.cc
index 309ae24..10a4252 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -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);
}
}
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index aa75368..74798c1 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -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);
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 1cfe122..af055b1 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -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:
diff --git a/glom/libglom/connectionpool.h b/glom/libglom/connectionpool.h
index 70f4b70..9d02170 100644
--- a/glom/libglom/connectionpool.h
+++ b/glom/libglom/connectionpool.h
@@ -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();
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 579fd79..a6808df 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -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);
diff --git a/glom/libglom/db_utils_export.cc b/glom/libglom/db_utils_export.cc
index 8afc023..785cd9a 100644
--- a/glom/libglom/db_utils_export.cc
+++ b/glom/libglom/db_utils_export.cc
@@ -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);
diff --git a/glom/libglom/init.h b/glom/libglom/init.h
index 19c73df..a86a1b9 100644
--- a/glom/libglom/init.h
+++ b/glom/libglom/init.h
@@ -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
diff --git a/glom/libglom/privs.cc b/glom/libglom/privs.cc
index 0fc7412..a4ebaca 100644
--- a/glom/libglom/privs.cc
+++ b/glom/libglom/privs.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);
diff --git a/glom/libglom/report_builder.cc b/glom/libglom/report_builder.cc
index 687c0c7..f999f5a 100644
--- a/glom/libglom/report_builder.cc
+++ b/glom/libglom/report_builder.cc
@@ -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);
diff --git a/glom/libglom/sql_utils.cc b/glom/libglom/sql_utils.cc
index 514d292..56adb5a 100644
--- a/glom/libglom/sql_utils.cc
+++ b/glom/libglom/sql_utils.cc
@@ -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
diff --git a/glom/libglom/sql_utils.h b/glom/libglom/sql_utils.h
index c7b852c..6bf4777 100644
--- a/glom/libglom/sql_utils.h
+++ b/glom/libglom/sql_utils.h
@@ -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
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 8bfcb7d..d5d5838 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -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))
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 2f25a51..335b651 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -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)
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 92e0bd8..24a3426 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -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);
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 61bb884..05ae670 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -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);
}
diff --git a/glom/mode_data/datawidget/dialog_choose_id.cc b/glom/mode_data/datawidget/dialog_choose_id.cc
index 337d848..7c8df8f 100644
--- a/glom/mode_data/datawidget/dialog_choose_id.cc
+++ b/glom/mode_data/datawidget/dialog_choose_id.cc
@@ -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);
}
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index cf98abb..2975186 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -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)
{
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index e315f7c..600f39d 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -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;
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index bb2f763..ef5bfb0 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -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))
diff --git a/tests/test_fake_connection.cc b/tests/test_fake_connection.cc
index 5ba141e..9433bd2 100644
--- a/tests/test_fake_connection.cc
+++ b/tests/test_fake_connection.cc
@@ -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)
{
diff --git a/tests/test_selfhosting_new_from_example_float.cc
b/tests/test_selfhosting_new_from_example_float.cc
index 077e6e0..8734353 100644
--- a/tests/test_selfhosting_new_from_example_float.cc
+++ b/tests/test_selfhosting_new_from_example_float.cc
@@ -52,23 +52,23 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Check that some data is as expected:
const auto pk_value = Gnome::Gda::Value::create_as_double(2.0l);
const Gnome::Gda::SqlExpr where_clause =
- Glom::Utils::build_simple_where_expression(table_name, primary_key_field, pk_value);
+ Glom::SqlUtils::build_simple_where_expression(table_name, primary_key_field, pk_value);
- Glom::Utils::type_vecLayoutFields fieldsToGet;
+ Glom::SqlUtils::type_vecLayoutFields fieldsToGet;
auto field = document->get_field(table_name, "price");
auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
layoutitem->set_full_field_details(field);
fieldsToGet.emplace_back(layoutitem);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
- Glom::Utils::build_sql_select_with_where_clause(table_name,
+ Glom::SqlUtils::build_sql_select_with_where_clause(table_name,
fieldsToGet, where_clause);
const Glib::RefPtr<const Gnome::Gda::DataModel> data_model =
Glom::DbUtils::query_execute_select(builder);
if(!test_model_expected_size(data_model, 1, 1))
{
std::cerr << G_STRFUNC << "Failure: Unexpected data model size with query: " <<
- Glom::Utils::sqlbuilder_get_full_query(builder) << std::endl;
+ Glom::SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
return false;
}
diff --git a/tests/test_selfhosting_new_then_image.cc b/tests/test_selfhosting_new_then_image.cc
index 5b1e98d..d3e9fc3 100644
--- a/tests/test_selfhosting_new_then_image.cc
+++ b/tests/test_selfhosting_new_then_image.cc
@@ -58,13 +58,13 @@ static bool test(Glom::Document::HostingMode hosting_mode)
}
const Gnome::Gda::SqlExpr where_clause =
- Glom::Utils::build_simple_where_expression(table_name, key_field, Gnome::Gda::Value(1));
+ Glom::SqlUtils::build_simple_where_expression(table_name, key_field, Gnome::Gda::Value(1));
//Set the value, from an image file:
const auto value_set = get_value_for_image();
g_assert(check_value_is_an_image(value_set));
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder_set =
- Glom::Utils::build_sql_update_with_where_clause(table_name,
+ Glom::SqlUtils::build_sql_update_with_where_clause(table_name,
field, value_set, where_clause);
const auto rows_affected = Glom::DbUtils::query_execute(builder_set);
if(!rows_affected)
@@ -75,13 +75,13 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Get the value:
- Glom::Utils::type_vecLayoutFields fieldsToGet;
+ Glom::SqlUtils::type_vecLayoutFields fieldsToGet;
auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
layoutitem->set_full_field_details(field);
fieldsToGet.emplace_back(layoutitem);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder_get =
- Glom::Utils::build_sql_select_with_where_clause(table_name,
+ Glom::SqlUtils::build_sql_select_with_where_clause(table_name,
fieldsToGet, where_clause);
auto data_model =
Glom::DbUtils::query_execute_select(builder_get);
diff --git a/tests/test_selfhosting_sqlinjection.cc b/tests/test_selfhosting_sqlinjection.cc
index 4cd8cc2..8369902 100644
--- a/tests/test_selfhosting_sqlinjection.cc
+++ b/tests/test_selfhosting_sqlinjection.cc
@@ -35,9 +35,9 @@ static bool check_get_extra_rows(const Glib::ustring& quote_char)
const Gnome::Gda::Value value("Born To Run" + quote_char + " OR " + quote_char + "x" + quote_char + "=" +
quote_char + "x");
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);
@@ -48,7 +48,7 @@ static bool check_get_extra_rows(const Glib::ustring& quote_char)
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);
auto data_model =
Glom::DbUtils::query_execute_select(builder);
@@ -68,9 +68,9 @@ static bool check_drop_table(const Glib::ustring& quote_char)
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,7 +81,7 @@ static bool check_drop_table(const Glib::ustring& quote_char)
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);
auto data_model =
Glom::DbUtils::query_execute_select(builder);
@@ -108,9 +108,9 @@ static bool check_avoid_quotes_and_drop_table_with_false_value_type()
auto where_field =
document->get_field("albums", "album_id");
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);
@@ -121,7 +121,7 @@ static bool check_avoid_quotes_and_drop_table_with_false_value_type()
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);
std::cout << "This test expects some std::cerr output about exceptions now:\n";
@@ -168,9 +168,9 @@ static bool check_avoid_quotes_and_drop_table_with_false_field_type()
//const GType gda_type = Glom::Field::get_gda_type_for_glom_type(Glom::TYPE_NUMERIC);
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);
@@ -181,7 +181,7 @@ static bool check_avoid_quotes_and_drop_table_with_false_field_type()
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);
Glib::RefPtr<Gnome::Gda::DataModel> data_model
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index 716d312..187991b 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -420,7 +420,7 @@ bool test_model_expected_size(const Glib::RefPtr<const Gnome::Gda::DataModel>& d
bool test_table_exists(const Glib::ustring& table_name, const std::shared_ptr<Glom::Document>& document)
{
//Try to get more rows than intended:
- Glom::Utils::type_vecLayoutFields fieldsToGet;
+ Glom::SqlUtils::type_vecLayoutFields fieldsToGet;
auto field = document->get_field_primary_key(table_name); //To to get some field.
if(!field)
{
@@ -433,7 +433,7 @@ bool test_table_exists(const Glib::ustring& table_name, const std::shared_ptr<Gl
fieldsToGet.emplace_back(layoutitem);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
- Glom::Utils::build_sql_select_with_where_clause(table_name,
+ Glom::SqlUtils::build_sql_select_with_where_clause(table_name,
fieldsToGet);
const Glib::RefPtr<const Gnome::Gda::DataModel> data_model =
Glom::DbUtils::query_execute_select(builder);
@@ -454,7 +454,7 @@ static bool test_example_musiccollection_data_related(const std::shared_ptr<cons
return false;
}
- Glom::Utils::type_vecLayoutFields fieldsToGet;
+ Glom::SqlUtils::type_vecLayoutFields fieldsToGet;
//Normal fields:
auto field_album_id = document->get_field("albums", "album_id");
@@ -490,13 +490,13 @@ static bool test_example_musiccollection_data_related(const std::shared_ptr<cons
fieldsToGet.emplace_back(layoutitem);
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
- Glom::Utils::build_sql_select_with_key("albums", fieldsToGet, field_album_id, album_id);
+ Glom::SqlUtils::build_sql_select_with_key("albums", fieldsToGet, field_album_id, album_id);
const Glib::RefPtr<const Gnome::Gda::DataModel> data_model =
Glom::DbUtils::query_execute_select(builder);
if(!test_model_expected_size(data_model, 3, 1))
{
std::cerr << G_STRFUNC << ": Failure: Unexpected data model size with query: " <<
- Glom::Utils::sqlbuilder_get_full_query(builder) << std::endl;
+ Glom::SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
return false;
}
@@ -514,9 +514,9 @@ bool test_example_musiccollection_data(const std::shared_ptr<const Glom::Documen
//Check that some data is as expected:
const Gnome::Gda::Value value("Born To Run");
const Gnome::Gda::SqlExpr where_clause =
- Glom::Utils::get_find_where_clause_quick(document, "albums", value);
+ Glom::SqlUtils::get_find_where_clause_quick(document, "albums", 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);
@@ -533,14 +533,14 @@ bool test_example_musiccollection_data(const std::shared_ptr<const Glom::Documen
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 Glib::RefPtr<const Gnome::Gda::DataModel> data_model =
Glom::DbUtils::query_execute_select(builder);
if(!test_model_expected_size(data_model, 2, 1))
{
std::cerr << G_STRFUNC << "Failure: Unexpected data model size with query: " <<
- Glom::Utils::sqlbuilder_get_full_query(builder) << std::endl;
+ Glom::SqlUtils::sqlbuilder_get_full_query(builder) << std::endl;
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]