2 unstable releases
Uses old Rust 2015
0.2.0 | Dec 24, 2018 |
---|---|
0.1.0 | Jun 5, 2017 |
#177 in #sql-query
7KB
90 lines
This plugin allows to generate simple SQL queries from Rust
struct. More specifically, it generates implementations of the
pleingres::Request
trait, replacing named variables (such as
$field
, which is invalid SQL) in the query by $1
in the query,
and calling pleingres::Buffer.bind
on self.field
.
It only works if the fields used in the query implement
pleingres::ToSql
, and if the type is a struct.
Example:
#![feature(plugin)]
#![plugin(sql)]
#[sql("SELECT id, is_active FROM users WHERE login = $user")]
pub struct UserReq {
pub user: String,
pub is_active: bool,
pub id: Option<Uuid>
}
Dependencies
~3.5MB
~71K SLoC