2个不稳定版本
使用旧的Rust 2015
0.2.0 | 2018年12月24日 |
---|---|
0.1.0 | 2017年6月5日 |
#178 in #sql-query
7KB
90 行
此插件允许从Rust结构体生成简单的SQL查询。更具体地说,它生成pleingres::Request特质的实现,用查询中的命名变量(如$field
,这是无效的SQL)替换查询中的$1
,并在self.field
上调用pleingres::Buffer.bind
。
它仅在查询中使用的字段实现pleingres::ToSql
并且类型是结构体时才有效。
示例
#![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>
}
依赖项
~3.5MB
~72K SLoC