-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
preparedstatements? #164
Comments
|
So for query parameters it is using a preparedstatement under the covers?
…On Tue, Apr 5, 2022 at 1:54 PM Johannes Müller ***@***.***> wrote:
crystal-db implicitly uses prepared statements by default, unless
configured otherwise.
—
Reply to this email directly, view it on GitHub
<#164 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAADBUG3YPT3LEAS2J3I3CLVDSK5XANCNFSM5STZPZLQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
By default, yes (and if the driver supports it, but AFAIK all existing drivers do). You can disable prepared statements in the connection config via |
Yeah that wasn't super clear...I may do a PR for it. Having "prepared statement" objects might be nice for named parameters, setting parameters separately, etc. but query parameters will work for now for me, thanks! Prepared statements might help with speed on occasion too I'm not sure. In more general feedback, it's also a bit odd that one driver has a different syntax for query parameters (i.e. prepared statements) than others, as well, though I guess that might be OK for now since few use different DB's. Cheers! |
Well, that syntax directly depends on the database. The drivers don't interpreter query parameters, they just pass the raw query to the server, thus it must use the specific parameter syntax of the respective database. |
You can use
Definitely! Prepared statements are cached, so the server doesn't need to re-interpret the same query again. |
For followers, it's like this in Postgres: b = db.build("select $1::int") Thanks. |
Add example of query parameters in a query, mention there are more helper methods available for query, mention preparedstatements are at play (crystal-lang/crystal-db#164).
Might be nice if prepared statements could be created in "block form" for auto-closing but maybe since they're manual that's not needed? |
Do they exist? If not, they are convenient at times, thanks!
The text was updated successfully, but these errors were encountered: