[gnome-db] Patch: guess_table_name.
- From: Bas Driessen <bas driessen xobas com>
- To: GNOME-DB List <gnome-db-list gnome org>
- Subject: [gnome-db] Patch: guess_table_name.
- Date: Thu, 20 Jan 2005 11:51:36 +1000
Hello,
Attached a patch for the Postgres provider. It is a small addition to the function "guess_table_name". At the moment guessing of the correct table name fails in the following example:
table 1: Parts; fields: part_id, desc, group_id, price
table 2: Groups; fields: group_id, desc
Since both fields of the groups table are also used in the parts table, the guess_table_name stores a NULL value since it can't guess which table is involved in the data model. By adding a check on column count, this problem is resolved.
The problem will probably continue to exist if I have to tables (Like Parts1 and Parts2), containing the same column names, having the same number of columns.
Please review and let me know if this change may/will break something.
The patches are for both head as 1.2. Since my previous round of changes are not updated yet in cvs, I could not use the cvs diff command. I based the diff on my local source tree which is the latest cvs + my changes from yesterday.
Thanks,
Bas.
--- ChangeLog.orig 2005-01-20 11:43:36.837988431 +1000
+++ ChangeLog 2005-01-20 11:35:41.482690325 +1000
@@ -1,3 +1,9 @@
+2005-01-20 Bas Driessen <bas driessen xobas com>
+
+ * providers/postgres/gda-postgres-recordset.c
+ (guess_table_name): improve table name guessing by
+ also checking on correct number of columns.
+
2005-01-19 Bas Driessen <bas driessen xobas com>
* libgda/gda-data-model-hash.c:
--- providers/postgres/gda-postgres-recordset.c.orig 2005-01-20 11:41:17.883244504 +1000
+++ providers/postgres/gda-postgres-recordset.c 2005-01-20 11:41:27.013847883 +1000
@@ -619,7 +619,7 @@
pg_conn = cnc_priv_data->pconn;
if (PQnfields (pg_res) > 0) {
- gchar *query = g_strdup_printf ("SELECT c.relname FROM pg_catalog.pg_class c WHERE c.relkind = 'r'");
+ gchar *query = g_strdup_printf ("SELECT c.relname FROM pg_catalog.pg_class c WHERE c.relkind = 'r' AND c.relnatts = '%d'", PQnfields (pg_res));
gint i;
for (i = 0; i < PQnfields (pg_res); i++) {
const gchar *column_name = PQfname (pg_res, i);
--- ChangeLog.orig 2005-01-20 11:31:01.998473421 +1000
+++ ChangeLog 2005-01-20 11:33:34.648081852 +1000
@@ -1,3 +1,9 @@
+2005-01-20 Bas Driessen <bas driessen xobas com>
+
+ * providers/postgres/gda-postgres-recordset.c
+ (guess_table_name): improve table name guessing by
+ also checking on correct number of columns.
+
2005-01-19 Bas Driessen <bas driessen xobas com>
* libgda/gda-data-model-hash.c:
--- providers/postgres/gda-postgres-recordset.c.orig 2005-01-20 11:28:49.136838654 +1000
+++ providers/postgres/gda-postgres-recordset.c 2005-01-20 11:30:33.336866855 +1000
@@ -617,7 +617,7 @@
pg_conn = cnc_priv_data->pconn;
if (PQnfields (pg_res) > 0) {
- gchar *query = g_strdup_printf ("SELECT c.relname FROM pg_catalog.pg_class c WHERE c.relkind = 'r'");
+ gchar *query = g_strdup_printf ("SELECT c.relname FROM pg_catalog.pg_class c WHERE c.relkind = 'r' AND c.relnatts = '%d'", PQnfields (pg_res));
gint i;
for (i = 0; i < PQnfields (pg_res); i++) {
const gchar *column_name = PQfname (pg_res, i);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]