boss_db icon indicating copy to clipboard operation
boss_db copied to clipboard

mysql: table/column names should be enclosed with `

Open danikp opened this issue 8 years ago • 1 comments

as stated in the title

danikp avatar Dec 24 '15 07:12 danikp

This just bit me, too! I had a column named "key" for a simple key/value store. And this is what happened:

boss_db:find_first(app_key_value, [{application, 'equals', "side.band"}, {key, 'equals', "url"}]).
14:29:34.360 [info] Query SELECT * FROM app_key_values WHERE key = 'url' AND application = 'side.band' AND  TRUE ORDER BY id ASC LIMIT 1 OFFSET 0
14:29:34.361 [error] SQL Error: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'url' AND application = 'side.band' AND  TRUE ORDER BY id ASC LIMIT 1 OFFS' at line 1"
** exception error: no function clause matching 
                    boss_db:return_one({error,"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key = 'url' AND application = 'side.band' AND  TRUE ORDER BY id ASC LIMIT 1 OFFS' at line 1"}) (src/boss_db.erl, line 598)

If it had encoded it as key it would have worked fine.

RobertSwirsky avatar Sep 27 '16 18:09 RobertSwirsky