Skip to content
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

Unable to serialize Option<_> bind #119

Closed
v3xro opened this issue Jul 30, 2024 · 2 comments · Fixed by #120
Closed

Unable to serialize Option<_> bind #119

v3xro opened this issue Jul 30, 2024 · 2 comments · Fixed by #120
Labels
enhancement New feature or request

Comments

@v3xro
Copy link
Contributor

v3xro commented Jul 30, 2024

Trying to write

client
  .query("SELECT ?fields FROM table WHERE nullable_field = ?")
  .bind(None)

fails at runtime with:

invalid param: invalid SQL: invalid argument: serialize_none is unsupported

The pattern of having nullable binds is quite common in server-side applications so I would have expected Option<_> support in binds somewhere (or maybe I missed it).

@loyd
Copy link
Collaborator

loyd commented Aug 4, 2024

optional filters

Do you mean filters that can either be provided or not by user? Yes, it's quite common, but implementation is tricky without parsing SQL. I mean, the filter should be totally ignored in such case

@loyd loyd added the enhancement New feature or request label Aug 4, 2024
@v3xro
Copy link
Contributor Author

v3xro commented Aug 5, 2024

optional filters

Do you mean filters that can either be provided or not by user? Yes, it's quite common, but implementation is tricky without parsing SQL. I mean, the filter should be totally ignored in such case

I've simplified the example above to not include that (though ofc you should be able to write (? IS NULL OR ? = some_nullable_field) (mostly leaving this comment for search reasons unless this should be included in examples)

@loyd loyd closed this as completed in #120 Aug 7, 2024
loyd added a commit that referenced this issue Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants