GNOME Bugzilla – Bug 661164
GdaSqlBuilder: "AS" alias names not quoted.
Last modified: 2011-10-17 18:49:18 UTC
Alias names added with gda_sql_builder_select_add_target() are not quoted when used with "AS" in the SQL, when using gda_sql_builder_select_join_targets(). SQL execution then fails. This test case shows that. It apparently generates this SQL: SELECT "songs"."songs_id", "songs"."album_id", "ALBUMS"."name" FROM "songs" LEFT JOIN "albums" AS ALBUMS ON (("songs"."album_id" = "ALBUMS"."album_id")) WHERE ("songs"."songs_id" = 0) instead of this: SELECT "songs"."songs_id", "songs"."album_id", "ALBUMS"."name" FROM "songs" LEFT JOIN "albums" AS "ALBUMS" ON (("songs"."album_id" = "ALBUMS"."album_id")) WHERE ("songs"."songs_id" = 0)
Created attachment 198517 [details] test_libgda_unquoted_as.c
Created attachment 198518 [details] [review] test_libgda_unquoted_as.c This patch fixes it, but I doubt that gda_sql_identifier_force_quotes() is quite the right function to call, and I doubt that this is quite the right place to call it.
Please see correction in commit http://git.gnome.org/browse/libgda/commit/?id=b115fd0fd586ce225f020575a25bad42eb3473b2 I still need some other corrections so check won't fail. Vivien
Thanks. That fixes it for me. + if ((*field->as != '\'') && (*field->as != '"')) This is repeated. I guess the code might be slightly simpler if there is a utility function for this.
Done: http://git.gnome.org/browse/libgda/commit/?id=e2025f2a6611507f4c6123a71abb17e479871f68 Vivien