Compile-time conditional queries for SQLx

3 releases

0.1.3 Jul 12, 2023
0.1.2 Feb 16, 2023
0.1.1 Feb 15, 2023

#1188 in Database interfaces

Download history 111/week @ 2023-08-09 269/week @ 2023-08-16 358/week @ 2023-08-23 258/week @ 2023-08-30 252/week @ 2023-09-06 168/week @ 2023-09-13 138/week @ 2023-09-20 208/week @ 2023-09-27 125/week @ 2023-10-04 276/week @ 2023-10-11 295/week @ 2023-10-18 381/week @ 2023-10-25 171/week @ 2023-11-01 138/week @ 2023-11-08 181/week @ 2023-11-15 136/week @ 2023-11-22

679 downloads per month



Conditional compile-time verified queries with SQLx

github crates.io docs.rs

This crate provides a macro for generating conditional compile-time verified queries while using the SQLx query_as! macro. This allows you to have parts of the query conditional in ways in which your chosen database doesn't allow by emitting multiple query_as! invocations that are chosen over by a match statement.

Variant growth

Note that this means that we end up emitting as many query_as! invocations as there are elements in the Cartesian product of all of the different conditionals. This means that the number of variants increase very rapidly!


Which database type should be supported is specified by activating one of the following features. If more than one feature is activated then the first one in the list takes precedence.

  • postgres
  • mysql
  • sqlite


Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~27K SLoC