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

index a8416ff28d4ffcfb5dfe520efd29ab96e6586e61..d86dd074b4e43a4c6b3ba68d8cc0dd14187ece92 100644 (file)
@@ -620,6 +620,36 @@ gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
        return id;
 }
 
+GdaSqlBuilderId
+gdaex_sql_builder_where_float (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+                               const gchar *table_name,
+                               const gchar *field_name,
+                               const gchar *field_alias,
+                               GdaSqlOperatorType where_op,
+                               gfloat op1,
+                               gfloat op2)
+{
+       GValue *val1;
+       GValue *val2;
+
+       GdaSqlBuilderId id;
+
+       val1 = g_new0 (GValue, 1);
+       g_value_init (val1, G_TYPE_FLOAT);
+       g_value_set_float (val1, op1);
+
+       val2 = g_new0 (GValue, 1);
+       g_value_init (val2, G_TYPE_FLOAT);
+       g_value_set_float (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_string (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
                                 const gchar *table_name,
index f35517269020465df1800a8be0142a1ede4afa54..4866121a9c74c638ff8d0a8c8d121d1be8fcdaa2 100644 (file)
@@ -84,6 +84,13 @@ GdaSqlBuilderId gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperat
                                              GdaSqlOperatorType where_op,
                                              gint op1,
                                              gint op2);
+GdaSqlBuilderId gdaex_sql_builder_where_float (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+                                               const gchar *table_name,
+                                               const gchar *field_name,
+                                               const gchar *field_alias,
+                                               GdaSqlOperatorType where_op,
+                                               gfloat op1,
+                                               gfloat op2);
 GdaSqlBuilderId gdaex_sql_builder_where_string (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
                                                 const gchar *table_name,
                                                 const gchar *field_name,
index 571261c7a77592643f1c112e478988f302cdaa99..d4cc1c2642609418b5da0cce27cdacaad637b62d 100644 (file)
@@ -192,6 +192,11 @@ main (int argc, char **argv)
                                         GDA_SQL_OPERATOR_TYPE_EQ,
                                         TRUE, FALSE);
 
+       gdaex_sql_builder_where_float (sqlb, 0,
+                                      "pippo", "income", "",
+                                      GDA_SQL_OPERATOR_TYPE_GEQ,
+                                      823.44, 0.0);
+
        g_message ("sql: %s", gdaex_sql_builder_get_sql (sqlb, NULL, NULL));
 
        g_object_unref (sqlb);