sorccu / rust-postgres-macros

Support macros for Rust-Postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!

About

Support macros for Rust-Postgres

License:MIT License


Languages

Language:Rust 69.4%Language:C 19.8%Language:Makefile 10.7%