Replies: 1 comment 1 reply
-
Hello, and welcome to necroposting. There are sqlx_conditional_queries for this purpose (41 stars on github) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been trying out SQLX in the context of building a REST API as opposed to using an ORM like Diesel or Sea ORM. One friction I'm running into that I don't see an obvious solution for is how to conditionally add filters to the query (i.e. where conditions).
I tried working with the QueryBuilder to achieve this but struggled to find a clean implementation that avoided any SQL injection vulnerabilities. I finally landed on this solution using the
query_as!
macro, but was wondering if anyone else has solved this in a more elegant way:Beta Was this translation helpful? Give feedback.
All reactions