[libgda] Correct use of gda_sql_builder_add_function() with no ID.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Correct use of gda_sql_builder_add_function() with no ID.
- Date: Thu, 20 May 2010 10:36:23 +0000 (UTC)
commit 6ff0e99ec51c90365a6e303cd8a6155d0c9246f6
Author: Murray Cumming <murrayc murrayc com>
Date: Thu May 20 12:22:56 2010 +0200
Correct use of gda_sql_builder_add_function() with no ID.
* libgda/gda-sql-builder.c: gda_sql_builder_add_function():
Check for a null function name.
* providers/reuseable/mysql/gda-mysql-reuseable.c
* providers/reuseable/postgres/gda-postgres-reuseable.c
* tests/test-sql-builder.c: Correct use of
gda_sql_builder_add_function() now that the id parameter is gone.
The compiler did not find these because it is a ... function.
libgda/gda-sql-builder.c | 1 +
providers/reuseable/mysql/gda-mysql-reuseable.c | 4 ++--
.../reuseable/postgres/gda-postgres-reuseable.c | 4 ++--
tests/test-sql-builder.c | 12 ++++++------
4 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index 822f5ef..44dbce8 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -1481,6 +1481,7 @@ gda_sql_builder_add_function (GdaSqlBuilder *builder, const gchar *func_name, ..
{
g_return_val_if_fail (GDA_IS_SQL_BUILDER (builder), 0);
g_return_val_if_fail (builder->priv->main_stmt, 0);
+ g_return_val_if_fail (func_name && *func_name, 0);
GdaSqlExpr *expr;
GSList *list = NULL;
diff --git a/providers/reuseable/mysql/gda-mysql-reuseable.c b/providers/reuseable/mysql/gda-mysql-reuseable.c
index d544027..8627815 100644
--- a/providers/reuseable/mysql/gda-mysql-reuseable.c
+++ b/providers/reuseable/mysql/gda-mysql-reuseable.c
@@ -158,8 +158,8 @@ _gda_mysql_compute_version (GdaConnection *cnc, GdaMysqlReuseable *rdata, GError
GdaDataModel *model;
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
- gda_sql_builder_add_function (b, 1, "version", 0);
- gda_sql_builder_add_field_id (b, 1, 0);
+ const guint id_func = gda_sql_builder_add_function (b, "version", 0);
+ gda_sql_builder_add_field_id (b, id_func, 0);
stmt = gda_sql_builder_get_statement (b, NULL);
g_object_unref (b);
g_assert (stmt);
diff --git a/providers/reuseable/postgres/gda-postgres-reuseable.c b/providers/reuseable/postgres/gda-postgres-reuseable.c
index 4574449..96e2f52 100644
--- a/providers/reuseable/postgres/gda-postgres-reuseable.c
+++ b/providers/reuseable/postgres/gda-postgres-reuseable.c
@@ -184,8 +184,8 @@ _gda_postgres_compute_version (GdaConnection *cnc, GdaPostgresReuseable *rdata,
GdaDataModel *model;
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
- gda_sql_builder_add_function (b, 1, "version", 0);
- gda_sql_builder_add_field_id (b, 1, 0);
+ const guint id_func = gda_sql_builder_add_function (b, "version", 0);
+ gda_sql_builder_add_field_id (b, id_func, 0);
stmt = gda_sql_builder_get_statement (b, NULL);
g_object_unref (b);
g_assert (stmt);
diff --git a/tests/test-sql-builder.c b/tests/test-sql-builder.c
index 1880b33..d6480bb 100644
--- a/tests/test-sql-builder.c
+++ b/tests/test-sql-builder.c
@@ -518,17 +518,17 @@ build12 (void)
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
gda_sql_builder_add_field_id (b, gda_sql_builder_add_id (b, 0, "store_name"), 0);
- gda_sql_builder_add_function (b, 1, "sum",
+ const guint id_func = gda_sql_builder_add_function (b, "sum",
gda_sql_builder_add_id (b, 0, "sales"), 0);
- gda_sql_builder_add_field_id (b, 1, 0);
+ gda_sql_builder_add_field_id (b, id_func, 0);
gda_sql_builder_select_add_target_id (b, 0,
- gda_sql_builder_add_id (b, 0, "stores"),
+ gda_sql_builder_add_id (b, "stores"),
NULL);
- gda_sql_builder_select_group_by (b, gda_sql_builder_add_id (b, 0, "store_name"));
+ gda_sql_builder_select_group_by (b, gda_sql_builder_add_id (b, "store_name"));
gda_sql_builder_select_set_having (b,
- gda_sql_builder_add_cond (b, 0, GDA_SQL_OPERATOR_TYPE_GT,
- 1,
+ gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_GT,
+ id_func,
gda_sql_builder_add_expr (b, 0, NULL,
G_TYPE_INT, 10),
0));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]