kyrias / sqlx-conditional-queries

Conditional compile-time verified queries with SQLx
Apache License 2.0
30 stars 4 forks source link

Return a plain `query_as!` invocation in the case of no compile-time conditions #3

Open kyrias opened 1 year ago

kyrias commented 1 year ago

Currently if we ended up having no compile-time conditional variation we end up creating a fake match expression so that the rest of the code can look the same. It would be nice if we could make the macro generate a simple query_as! without the whole map type indirection.

Using the conditional_query_as! macro can be useful even when there's no compile-time variability since it allows for referring to bound parameters by name rather than having to keep track and update the order of binding references manually.

https://github.com/kyrias/sqlx-conditional-queries/blob/363c9108515efcbdc3f3a1a3613850ab52dc93dc/core/src/lower.rs#L99-L100