Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL and quoting #20

Closed
jartur opened this issue Nov 16, 2011 · 5 comments
Closed

MySQL and quoting #20

jartur opened this issue Nov 16, 2011 · 5 comments

Comments

@jartur
Copy link

jartur commented Nov 16, 2011

There is an issue with MySQL which is more on MySQL side but still. The thing is that MySQL doesn't by default use double quotes to quote field names. It uses backtiks. And double quotes are reserved for string literals. So, basically out of the box Korma doesn't work with MySQL. There is a workaround which is to run (exec-raw "set sql_mode='ANSI_QUOTES'") before executing any queries. But I'm not sure if this will work with multiple connections from pool, unless one would run the aforementioned query before executing any other query. Also it may be possible to change this in MySQL config but that is not always an option. So, what I would like to see is an ability to set quoting character in Korma itself. And maybe even predefined quoting characters for different database types.

@ibdknox
Copy link
Member

ibdknox commented Nov 17, 2011

(korma.core/set-delimiters "`") should do the trick :)

0.3.0-alpha2 has the change.

@ibdknox ibdknox closed this as completed Nov 17, 2011
@jartur
Copy link
Author

jartur commented Nov 17, 2011

Thanks for such short reaction time.

@gberenfield
Copy link

I think this is an issue again with 0.3.0-alpha5. The delimiter atom is changed but doesn't seem to be picked up in the actual delimit-str call (using korma.config/set-delimiters).

@ibdknox
Copy link
Member

ibdknox commented Nov 29, 2011

Are you setting it before you define you do (defdb)? If so, just move it after and it should work (I'll make that smarter). A much better, and brand new, solution is to do it as part of your defdb:

(defdb prod (mysql {:db "blah" :user "blah" :password "hey" :delimiters "`"}))

@gberenfield
Copy link

That did it, ty :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants