join clause uses " delimiters, not ` delimiters as used in the rest of the query

47 views
Skip to first unread message

Michael Pheasant

unread,
Apr 22, 2013, 9:39:10 AM4/22/13
to sqlk...@googlegroups.com
Hi,

I have an entity table_a, and a related 'joined_table', defined as follows:

(defentity table_a
  (entity-fields  :id :pos :from :to)
  (belongs-to joined_table))

I have a mysql connection, (defdb mydb (mysql {:db ...etc...
The connection is created with connection delimiters ' :delimiters [\` \`],'

Yet I get a MySQL SQL error when I include the joined table in a 'with' clause. The JOIN clause uses double-quotes as delimiter, even though the rest of the query uses the right \` delimiters, as below:

(select table_a (with joined_table) (limit 10))
Failure to execute query with SQL:
SELECT `table_a`.*, `joined_table`.* FROM `table_a` LEFT JOIN `joined_table` ON "joined_table"."id" = "table_a"."joined_table_id" LIMIT 10  ::  []
MySQLSyntaxErrorException:
 Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."id" = "table_a"."joined_table_id" LIMIT 10' at line 1
 SQLState: 42000
 Error Code: 1064
MySQLSyntaxErrorException You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '."id" = "table_a"."joined_table_id" LIMIT 10' at line 1  sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)


Am I doing something wrong? 
Cant figure this out, and cant see the problem reported by others.

Cheers
Mike

Michael Pheasant

unread,
Apr 22, 2013, 6:59:15 PM4/22/13
to sqlk...@googlegroups.com
Hmm, seems like its something to do with interactive work, and using default delimiters (") that have not been overridden by the mysql connection yet.

A top-level (set-delimiters "`") form above my defentity's, that evals before the defentity macros, fixes it.

- Any suggestions for best way to do this with mysql connections?

m
Reply all
Reply to author
Forward
0 new messages