[glom] Make querying fields of a database table work if the table name needs quotation
- From: Armin Burgmeier <arminb src gnome org>
- To: svn-commits-list gnome org
- Subject: [glom] Make querying fields of a database table work if the table name needs quotation
- Date: Tue, 30 Jun 2009 18:47:30 +0000 (UTC)
commit 54e7692051e0947c7b8b7a14e0932b45294ebf50
Author: Armin Burgmeier <armin arbur net>
Date: Tue Jun 30 19:54:52 2009 +0200
Make querying fields of a database table work if the table name needs quotation
* glom/base_db.cc (get_fields_for_table_from_database): Make this work
for table names which need quotation, and return unquoted field names.
This fixes bug #587051.
ChangeLog | 6 ++++++
glom/base_db.cc | 22 ++++++++++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3e18f5f..b9eb66a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-30 Armin Burgmeier <armin openismus com>
+
+ * glom/base_db.cc (get_fields_for_table_from_database): Make this work
+ for table names which need quotation, and return unquoted field names.
+ This fixes bug #587051.
+
2009-06-30 Murray Cumming <murrayc murrayc com>
get_table_names_from_database(): Remove quotes.
diff --git a/glom/base_db.cc b/glom/base_db.cc
index abaf237..c3bc8e0 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -572,7 +572,7 @@ static bool meta_table_column_is_primary_key(GdaMetaTable* meta_table, const Gli
if(!column)
continue;
- if(column->column_name && (column_name == column->column_name))
+ if(column->column_name && (column_name == remove_quotes(column->column_name)))
return column->pkey;
}
@@ -626,7 +626,19 @@ Base_DB::type_vec_fields Base_DB::get_fields_for_table_from_database(const Glib:
Glib::RefPtr<Gnome::Gda::Connection> connection = sharedconnection->get_gda_connection();
Glib::RefPtr<Gnome::Gda::Holder> holder_table_name = Gnome::Gda::Holder::create(G_TYPE_STRING, "name");
- holder_table_name->set_value(table_name);
+ Glib::ustring quoted_table_name;
+ if(gda_sql_identifier_needs_quotes(table_name.c_str()))
+ {
+ gchar* quoted_table_name_c = gda_sql_identifier_add_quotes(table_name.c_str());
+ quoted_table_name = quoted_table_name_c;
+ g_free(quoted_table_name_c);
+ }
+ else
+ {
+ quoted_table_name = table_name;
+ }
+
+ holder_table_name->set_value(quoted_table_name);
std::list< Glib::RefPtr<Gnome::Gda::Holder> > holder_list;
holder_list.push_back(holder_table_name);
@@ -668,7 +680,7 @@ Base_DB::type_vec_fields Base_DB::get_fields_for_table_from_database(const Glib:
GdaMetaDbObject* meta_dbobject = metastruct->complement(Gnome::Gda::META_DB_TABLE,
Gnome::Gda::Value(), /* catalog */
Gnome::Gda::Value(), /* schema */
- Gnome::Gda::Value(table_name)); //It's a static instance inside the MetaStore.
+ Gnome::Gda::Value(quoted_table_name)); //It's a static instance inside the MetaStore.
GdaMetaTable* meta_table = GDA_META_TABLE(meta_dbobject);
@@ -686,7 +698,9 @@ Base_DB::type_vec_fields Base_DB::get_fields_for_table_from_database(const Glib:
if(value_name.get_string().empty())
g_warning("Base_DB::get_fields_for_table_from_database(): value_name is empty.");
- field_info->set_name( value_name.get_string() ); //TODO: get_string() is a dodgy choice. murrayc.
+ Glib::ustring field_name = value_name.get_string(); //TODO: get_string() is a dodgy choice. murrayc.
+ field_name = remove_quotes(field_name);
+ field_info->set_name(field_name);
}
//Get the field type:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]