]> saetta.ns0.it Git - libgdaex/commitdiff
Added function ::get_gda_sqlbuilder_from_hashtable.
authorAndrea Zagli <azagli@libero.it>
Sat, 29 Aug 2020 14:55:15 +0000 (16:55 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 29 Aug 2020 14:55:15 +0000 (16:55 +0200)
src/gdaex.c
src/gdaex.h

index fe73fff1dc44dfd52f55748c71f0f74e2dc594dd..d3e574a75a3604561d105417dd4e7f29a60503f8 100644 (file)
@@ -3693,21 +3693,16 @@ gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
        gdaex_fill_liststore_from_datamodel_with_missing_func (gdaex, lstore, dm, cols_formatted, format_func, NULL, NULL);
 }
 
-const gchar
-*gdaex_get_sql_from_hashtable (GdaEx *gdaex,
-                               GdaExSqlType sqltype,
-                               const gchar *table_name,
-                               GHashTable *keys,
-                               GHashTable *fields)
+GdaSqlBuilder
+*gdaex_get_gda_sqlbuilder_from_hashtable (GdaEx *gdaex,
+                                          GdaExSqlType sqltype,
+                                          const gchar *table_name,
+                                          GHashTable *keys,
+                                          GHashTable *fields)
 {
-       gchar *ret;
        gchar *_table_name;
 
-       GError *error;
        GdaSqlBuilder *b;
-       GdaStatement *stmt;
-
-       GdaExPrivate *priv;
 
        GHashTableIter ht_iter_fields;
        GHashTableIter ht_iter_keys;
@@ -3721,18 +3716,14 @@ const gchar
        GdaSqlBuilderId id_value;
        GdaSqlBuilderId id_cond;
 
-       g_return_val_if_fail (IS_GDAEX (gdaex), "");
-       g_return_val_if_fail (table_name != NULL, "");
+       g_return_val_if_fail (IS_GDAEX (gdaex), NULL);
+       g_return_val_if_fail (table_name != NULL, NULL);
 
        _table_name = g_strstrip (g_strdup (table_name));
-       g_return_val_if_fail (g_strcmp0 (table_name, "") != 0, "");
-
-       priv = GDAEX_GET_PRIVATE (gdaex);
+       g_return_val_if_fail (g_strcmp0 (table_name, "") != 0, NULL);
 
        b = NULL;
 
-       ret = "";
-
        switch (sqltype)
                {
                        case GDAEX_SQL_SELECT:
@@ -3827,6 +3818,40 @@ const gchar
                                break;
                }
 
+       g_free (_table_name);
+
+       return b;
+}
+
+const gchar
+*gdaex_get_sql_from_hashtable (GdaEx *gdaex,
+                               GdaExSqlType sqltype,
+                               const gchar *table_name,
+                               GHashTable *keys,
+                               GHashTable *fields)
+{
+       GError *error;
+
+       GdaSqlBuilder *b;
+       GdaStatement *stmt;
+
+       GdaExPrivate *priv;
+
+       gchar *ret;
+
+       priv = GDAEX_GET_PRIVATE (gdaex);
+
+       b = gdaex_get_gda_sqlbuilder_from_hashtable (gdaex,
+                                                    sqltype,
+                                                    table_name,
+                                                    keys,
+                                                    fields);
+
+       if (b == NULL)
+               {
+                       return NULL;
+               }
+
        error = NULL;
        stmt = gda_sql_builder_get_statement (b, &error);
        if (stmt == NULL || error != NULL)
@@ -3855,8 +3880,6 @@ const gchar
                        g_object_unref (b);
                }
 
-       g_free (_table_name);
-
        return ret;
 }
 
index af559aef3b84acd034952c09f2bd63b25cce97aa..eca4fe89c76aaf57c7f80ff2f37b2bc727f3a7a0 100644 (file)
@@ -313,6 +313,12 @@ typedef enum
        GDAEX_SQL_DELETE
 } GdaExSqlType;
 
+GdaSqlBuilder *gdaex_get_gda_sqlbuilder_from_hashtable (GdaEx *gdaex,
+                                                        GdaExSqlType sqltype,
+                                                        const gchar *table_name,
+                                                        GHashTable *keys,
+                                                        GHashTable *fields);
+
 const gchar *gdaex_get_sql_from_hashtable (GdaEx *gdaex,
                                            GdaExSqlType sqltype,
                                            const gchar *table_name,