Compact SQL
A simple macros allows to write SQL queries for Postgres which will be compacted (and optionally checked) at compile-time.
Dependency
[]
= { = "https://gitlab.com/vitaly.burovoy/compact_sql", = "PoC" }
Pretty error
Use pretty-errors feature (requires unstable Rust version) if you can get better errors with pointing to a concrete error span.
[]
= { = "0.0.1", = ["pretty-errors"] }
Using Compact SQL
Generate just an SQL string
use pg_sql;
Note! There are allowed commas between keywords (more convenient for VCS), named parameters in curly braces are replaced with "$x" Postgres numbered parameters (the same number for the same names).
Common keywords like "SELECT", "AS", etc. are required (as warnings) to be uppercase.
Test SQL queries
If you want to check queries (via "prepare") you can define ENVs for the DBMS:
TEST_PG_HOSTTEST_PG_PORT(optional; default: 5432)TEST_PG_USER(optional; default: "postgres")TEST_PG_PASS(optional; default: "")TEST_PG_DATB
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.