[libgda/LIBGDA_4.0] SQL rendering correction
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.0] SQL rendering correction
- Date: Sun, 30 Aug 2009 10:44:41 +0000 (UTC)
commit 7a049902a9149df4dc6b14755de13cabc26674e1
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Aug 26 21:43:00 2009 +0200
SQL rendering correction
so that statements containing "EXISTS (SELECT ...)" will be
rendered correctly.
libgda/gda-statement.c | 12 +++++++++---
libgda/sqlite/gda-sqlite-provider.c | 10 ++++++++--
2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/libgda/gda-statement.c b/libgda/gda-statement.c
index d477404..ed75611 100644
--- a/libgda/gda-statement.c
+++ b/libgda/gda-statement.c
@@ -1370,8 +1370,14 @@ default_render_expr (GdaSqlExpr *expr, GdaSqlRenderingContext *context, gboolean
gchar *str1;
str1 = context->render_select (GDA_SQL_ANY_PART (expr->select), context, error);
if (!str1) goto err;
- str = g_strdup_printf ("(%s)", str1);
- g_free (str1);
+
+ if (! GDA_SQL_ANY_PART (expr)->parent ||
+ (GDA_SQL_ANY_PART (expr)->parent->type != GDA_SQL_ANY_SQL_FUNCTION)) {
+ str = g_strdup_printf ("(%s)", str1);
+ g_free (str1);
+ }
+ else
+ str = str1;
}
else if (expr->case_s) {
str = context->render_case (GDA_SQL_ANY_PART (expr->case_s), context, error);
@@ -1472,7 +1478,7 @@ default_render_function (GdaSqlFunction *func, GdaSqlRenderingContext *context,
if (!gda_sql_any_part_check_structure (GDA_SQL_ANY_PART (func), error)) return NULL;
string = g_string_new (func->function_name);
- g_string_append_c (string, '(');
+ g_string_append (string, " (");
for (list = func->args_list; list; list = list->next) {
if (list != func->args_list)
g_string_append (string, ", ");
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 1ce49f7..b0ae551 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -1560,8 +1560,14 @@ sqlite_render_expr (GdaSqlExpr *expr, GdaSqlRenderingContext *context,
else
str1 = context->render_compound (GDA_SQL_ANY_PART (expr->select), context, error);
if (!str1) goto err;
- str = g_strdup_printf ("(%s)", str1);
- g_free (str1);
+
+ if (! GDA_SQL_ANY_PART (expr)->parent ||
+ (GDA_SQL_ANY_PART (expr)->parent->type != GDA_SQL_ANY_SQL_FUNCTION)) {
+ str = g_strdup_printf ("(%s)", str1);
+ g_free (str1);
+ }
+ else
+ str = str1;
}
else if (expr->case_s) {
str = context->render_case (GDA_SQL_ANY_PART (expr->case_s), context, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]