-
Notifications
You must be signed in to change notification settings - Fork 88
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
Support custom queries in builder #403
Support custom queries in builder #403
Conversation
Tweaked the implementation to allow for a nil value, to support running a raw SQL string with no parameter substitutions. |
Added specs for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. I am wondering if this supports an array as a parameter where("id in ?", [1, 2, 3])
@Serdnad Does your |
@Blacksmoke16 This placeholder just tells the assembler that there's a placeholder in the query, so that the assembler can then replace this with the proper, final placeholder, such as @drujensen That's a good point. I just checked, and it seems like the array would have to be formatted as Edit: Actually, I'm not so sure about that last point. I'll do some testing. |
@Serdnad It can be treated as a separate issue. If @Blacksmoke16 approves, we can merge. |
@Serdnad this looks great! |
Thanks @robacarp ! This turned out very differently than what I was initially looking for, but definitely for the better. Huge thanks for all the input and feedback from all of you :) |
This is a first attempt at addressing #402 , and implements support for building simple queries through the use of handwritten SQL like so:
with the intention of providing a way to support more sophisticated queries, such as
and even database specific features, like checking for membership in an array using Postgres:
The current implementation only allows one argument per query, but it should be rather straightforward to extend this to allow multiple args per query, if that's desired.
A simple spec is included for each DB adapter.
Note: I've opened this PR as a draft because I also intend to include an addition to the docs, but wanted to make this available for review as early as possible.