-
Notifications
You must be signed in to change notification settings - Fork 48
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
Postgres Support #20
Postgres Support #20
Conversation
But if the on_duplicate feature is used, the generated SQL is going to be invalid because postgres doesn't support INSERT IGNORE and ON DUPLICATE KEY UPDATE features out-of-box yet. What would be an appropriate solution for this? An alert or stop the process? |
Hey, @derencius. I agree that it would make sense to raise an exception when someone tries to use Btw, can you rebase your branch on top of master as opposed to merging it? That way it would keep Polo's history cleaner. After you do that, can you please squash all the commits and use this standard for the commit message? This is looking awesome! Can't wait to 🚢 this! |
@derencius @nettofarah AFAIK postgres will start supporting something similar to INSERT IGNORE or ON DUPLICATE UPDATE starting on 9.5 https://wiki.postgresql.org/wiki/UPSERT |
By the way, does this feature work with associations? When I tried this branch, it didn't work for me. It only generated the "base" insert statement @derencius |
I sounds like we're gonna have to tackle #23 before we fiddle with this PR some more. What do y'all think? |
@bbonamin how did you try it? did you specify the branch in your Gemfile?
|
Because postgres can use prepared statments, Polo was failing to capture generated SQL. Disabling prepared statements while capturing the queries fixed this issue. Rails earlier than version 4.0.1 doesn't have support to prepared statements, so the call to unprepared_statement should be prevented. fixes support for rails < 4.0.1, that doesn't have unprepared_statments
@nettofarah not sure about the way to prevent the usage of |
@derencius I think we could leave this as is for now, assuming everything works. We could implement a postgres one that just raises an error when trying to use one of these features in run time. Another option would be to check when calling In any case, I think your PR looks great, and we should be able to merge it at any time. We can open a new issue for the |
@derencius I just tried again and it follows associations as you would expect! My bad 😄 |
Alright alright! congrats @derencius on your awesome PR. |
💯 🎉 |
This pull request will allow the basic features of polo to work with postgres.