]> saetta.ns0.it Git - libgdaex/commitdiff
Added function GdaExSqlBuilder::where_boolean.
authorAndrea Zagli <azagli@libero.it>
Wed, 2 Oct 2019 13:42:00 +0000 (15:42 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 3 Oct 2019 13:40:41 +0000 (15:40 +0200)
src/sqlbuilder.c
src/sqlbuilder.h
tests/sqlbuilder.c

index 0af320f70e432aa980d0144a430769c8f56f0efa..a8416ff28d4ffcfb5dfe520efd29ab96e6586e61 100644 (file)
@@ -560,6 +560,36 @@ gdaex_sql_builder_where (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op, ...)
        return priv->id_where;
 }
 
+GdaSqlBuilderId
+gdaex_sql_builder_where_boolean (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+                                 const gchar *table_name,
+                                 const gchar *field_name,
+                                 const gchar *field_alias,
+                                 GdaSqlOperatorType where_op,
+                                 gboolean op1,
+                                 gboolean op2)
+{
+       GValue *val1;
+       GValue *val2;
+
+       GdaSqlBuilderId id;
+
+       val1 = g_new0 (GValue, 1);
+       g_value_init (val1, G_TYPE_BOOLEAN);
+       g_value_set_boolean (val1, op1);
+
+       val2 = g_new0 (GValue, 1);
+       g_value_init (val2, G_TYPE_BOOLEAN);
+       g_value_set_boolean (val2, op2);
+
+       id = gdaex_sql_builder_where (sqlb, op, table_name, field_name, field_alias, where_op, val1, val2, NULL);
+
+       g_value_unset (val1);
+       g_value_unset (val2);
+
+       return id;
+}
+
 GdaSqlBuilderId
 gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
                              const gchar *table_name,
index b21066407f8288d6b5f6ab761bb37547130069b9..f35517269020465df1800a8be0142a1ede4afa54 100644 (file)
@@ -70,6 +70,13 @@ void gdaex_sql_builder_fields (GdaExSqlBuilder *sqlb, ...);
 
 GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
                                                                                 ...);
+GdaSqlBuilderId gdaex_sql_builder_where_boolean (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+                                                 const gchar *table_name,
+                                                 const gchar *field_name,
+                                                 const gchar *field_alias,
+                                                 GdaSqlOperatorType where_op,
+                                                 gboolean op1,
+                                                 gboolean op2);
 GdaSqlBuilderId gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
                                              const gchar *table_name,
                                              const gchar *field_name,
index 1e5de7a113a2b5ad8bf814fa112de80819e44e06..571261c7a77592643f1c112e478988f302cdaa99 100644 (file)
@@ -187,6 +187,11 @@ main (int argc, char **argv)
                                     GDA_SQL_OPERATOR_TYPE_BETWEEN,
                                     1, 99);
 
+       gdaex_sql_builder_where_boolean (sqlb, 0,
+                                        "pippo", "married", "",
+                                        GDA_SQL_OPERATOR_TYPE_EQ,
+                                        TRUE, FALSE);
+
        g_message ("sql: %s", gdaex_sql_builder_get_sql (sqlb, NULL, NULL));
 
        g_object_unref (sqlb);