boss_db
boss_db copied to clipboard
mysql: table/column names should be enclosed with `
as stated in the title
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.