]> saetta.ns0.it Git - gdadbcopy/commitdiff
Fields creation.
authorAndrea Zagli <azagli@libero.it>
Wed, 21 Nov 2012 21:17:24 +0000 (22:17 +0100)
committerAndrea Zagli <azagli@libero.it>
Wed, 21 Nov 2012 21:17:24 +0000 (22:17 +0100)
src/main.c
tests/db.db

index bc3b3565318585a5f5dc2e67bb06da2aad61e80a..001de4a457fb674dd204541da52108946ba05292 100644 (file)
@@ -60,7 +60,7 @@ update_metastore ()
 }
 
 static void
-read_fields (const gchar *table_name)
+read_fields (const gchar *table_name, GdaServerOperation *op)
 {
        GError *error;
 
@@ -108,6 +108,25 @@ read_fields (const gchar *table_name)
                                                gda_value_stringify (gda_data_model_get_value_at (dm_fields, 2, row, NULL)),
                                                g_value_get_int (gda_data_model_get_value_at (dm_fields, 3, row, NULL)),
                                                g_value_get_int (gda_data_model_get_value_at (dm_fields, 4, row, NULL)));
+
+                                       if (!gda_server_operation_set_value_at (op,
+                                                                               gda_value_stringify (gda_data_model_get_value_at (dm_fields, 0, row, NULL)),
+                                                                               &error,
+                                                                               g_strdup_printf ("/FIELDS_A/@COLUMN_NAME/%d", row)))
+                                               {
+                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
+                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                       continue;
+                                               }
+                                       if (!gda_server_operation_set_value_at (op,
+                                                                               gda_value_stringify (gda_data_model_get_value_at (dm_fields, 1, row, NULL)),
+                                                                               &error,
+                                                                               g_strdup_printf ("/FIELDS_A/@COLUMN_TYPE/%d", row)))
+                                               {
+                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
+                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                       continue;
+                                               }
                                }
                }
        if (dm_fields != NULL)
@@ -163,22 +182,7 @@ read_tables ()
                                                        continue;
                                                }
 
-                                       /*read_fields (gdacon, table_name);*/
-                                       if (!gda_server_operation_set_value_at (op, "id", &error, 
-                                                                               "/FIELDS_A/@COLUMN_NAME/0"))
-                                               {
-                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
-                                                                  error != NULL && error->message != NULL ? error->message : "no details");
-                                                       continue;
-                                               }
-                                       if (!gda_server_operation_set_value_at (op, "INTEGER", &error, 
-                                                                               "/FIELDS_A/@COLUMN_TYPE/0"))
-                                               {
-                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
-                                                                  error != NULL && error->message != NULL ? error->message : "no details");
-                                                       continue;
-                                               }
-
+                                       read_fields (table_name, op);
 
                                        error = NULL;
                                        if (!gda_connection_perform_operation (gda_conn_db, op, &error))
index 66bc769b6a3320a6265120f2fc0a5e3a7c7efa6e..aa2abdd6b9cfe1fa1397a7dab066c9cf65a94fa5 100644 (file)
Binary files a/tests/db.db and b/tests/db.db differ