Support macros for Rust-Postgres
Rust C Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml Test on nightlies May 26, 2015
Cargo.toml Release v0.1.13 Dec 18, 2016
LICENSE-APACHE Relicense to dual MIT/Apache-2.0 Jan 11, 2016
LICENSE-MIT Relicense to dual MIT/Apache-2.0 Jan 11, 2016
Makefile
README.md Relicense to dual MIT/Apache-2.0 Jan 11, 2016
THIRD_PARTY Download source instead of using a submodule Nov 22, 2014
build.rs Stop build if make failed Jun 8, 2015

README.md

rust-postgres-macros

A set of support macros for Rust-Postgres.

Build Status

You can integrate rust-postgres-macros into your project through the releases on crates.io:

# Cargo.toml
[dependencies]
postgres_macros = "0.1"

sql!

The sql! macro will validate that its string literal argument parses as a valid Postgres query.

#![feature(plugin)]
#![plugin(postgres_macros)]

fn main() {
    let query = sql!("SELECT * FROM users WHERE name = $1");
    let bad_query = sql!("SELECT * FORM users WEHRE name = $1");
}
test.rs:8:26: 8:63 error: Invalid syntax at position 10: syntax error at or near "FORM"
test.rs:8     let bad_query = sql!("SELECT * FORM users WEHRE name = $1");
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Credits

Major thanks to pganalyze for their writeup on how to link to the Postgres query parser directly!

License

Licensed under either of

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.