-
Notifications
You must be signed in to change notification settings - Fork 36
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
v5.40's builtin false keyword cannot be passed in a bind parameter as the value of a boolean field #125
Comments
I could be mistaken, as I'm just going by what I've read, but I don't think you need Perl v5.40 for this. |
starting with 5.36, even
|
You're not stuck with the builtin bools; you can explicitly pass |
But typing JSON::PP::true (or a variable containing that value) is tedious. Would be much nicer to use the builtins, else would be easier to type int before true/false/a condition evaluating to builtin boolean. If the maintainer of DBD::Pg does not intend to adapt to 5.40’s builtin booleans, I’ll just monkey-patch Mojo::Pg in my projects to achieve the desired result. But if I’m not mistaken this would be a welcome change in the Perl community. The ability to pass the native true & false as boolean field bind arguments. |
Maintaining DBD::Pg is nobody's full-time job. What we need is someone to submit a PR. I'm sure a PR would be most welcome by all. I say this strictly as an observer and proponent of this project who has contributed a couple PRs over the years. |
I think the part that needs updating is written in C/XS or something like that. I can’t do that. |
I didn't say "you." I said "someone." 😄 My point was that it's a community effort. |
For now I implememted a fix on my projects, by subclassing Mojo::Pg. That's good enough for me, for now. |
Maybe, to avoid breaking backwards-compatibility, there could be an Option, for converting built in booleans to Pg Booleans. And maybe another option also, for converting Pg Booleans to perl's built in booleans, when issuing a SELECT query! |
I'm not actually convinced that this is a bug in DBD::Pg! After trying to write a failing test, i discovered that when a bind param is set as |
Either way, it would be good if this repo decided on a course (one way or another), so that after that we can press our query engines to adapt (if DBD::Pg doesn't). |
I think it would make sense to always bind native booleans as |
Note that using a "real" perl boolean false (e.g.
Since 5.36 we can at least detect it and bind it as |
I believe binding false as |
#129 implements my above suggestion, and adds tests and documentation. |
@ilmari Thanks, dude |
I just had a thought (and pushed a commit to do it, for discussion): should we respect |
Seems reasonable to me. Thanks! |
This seems like it's a bad thing, because writing
use v5.40;
on a script doesn't let you override thetrue
&false
builtins afterwards by using something likeuse Mojo::JSON qw/ true false /;
, nor withno builtin qw/ true false /
, so we're all stuck with v5.40's builtin boolean values, and maybe you should consider this.DBD::Pg thinks
false
is an empty string, and PostgreSQL returns an error:My example script:
Output:
The text was updated successfully, but these errors were encountered: