-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Simplier prepared statement #12
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
Comments
So I've done some reading & it seems like the '?' syntax is only for drivers which do client-side substitution of prepared statement values. The "$1" "$2" syntax is the officially supported syntax of PostgreSQL. What driver did you previously use which used the '?' syntax? I'll dig deeper into how that driver was implemented & see why/how they used ?'s. |
I've used DBI:Pg in Perl (http://search.cpan.org/~rudy/DBD-Pg-1.32/Pg.pm) But now that you mention it, I think they do some server-side substitution before it gets to the database. I didn't know that was the internal syntax so maybe that's good to keep, it's just nicer to write: Then: And have to keep track of the numbers, could be more error prone but not the end of the world either. |
I'm going to close this one for now. Don't think adding ?'s instead of $1's is really the right move since the prepared statement happens on the server and the server demands $1 style parameters. In fact, I tried using ?'s and the server got angry at me. :) Still considering implementing ? and $1 style replacement on the client side before sending to Postgres as an option, but it would have to be explicit with some pg.escape(string, [params]) type of function. |
You may have already dealt with this but it would be helpful to just use ? like in perl for a placeholder instead of $1 $2 etc... easier to type and don't have to worry about numbering. Just a thought.
The text was updated successfully, but these errors were encountered: