After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 661164 - GdaSqlBuilder: "AS" alias names not quoted.
GdaSqlBuilder: "AS" alias names not quoted.
Status: RESOLVED FIXED
Product: libgda
Classification: Other
Component: Client library
4.99.x
Other Linux
: Normal normal
: ---
Assigned To: malerba
gnome-db Maintainers
Depends on:
Blocks: 661073
 
 
Reported: 2011-10-07 10:09 UTC by Murray Cumming
Modified: 2011-10-17 18:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test_libgda_unquoted_as.c (2.11 KB, text/plain)
2011-10-07 10:10 UTC, Murray Cumming
  Details
test_libgda_unquoted_as.c (824 bytes, patch)
2011-10-07 10:11 UTC, Murray Cumming
needs-work Details | Review

Description Murray Cumming 2011-10-07 10:09:26 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)
Comment 1 Murray Cumming 2011-10-07 10:10:12 UTC
Created attachment 198517 [details]
test_libgda_unquoted_as.c
Comment 2 Murray Cumming 2011-10-07 10:11:12 UTC
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.
Comment 3 malerba 2011-10-10 19:41:20 UTC
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
Comment 4 Murray Cumming 2011-10-11 10:28:58 UTC
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.