#codegen #orm #postgresql #sql

diesel_codegen_syntex

Allows use of diesel_codegen with syntex

5 unstable releases

Uses old Rust 2015

0.9.0 Dec 8, 2016
0.8.0 Oct 10, 2016
0.7.2 Aug 20, 2016
0.7.1 Aug 11, 2016
0.7.0 Aug 1, 2016

#1909 in Database interfaces

41 downloads per month

MIT/Apache

2MB
33K SLoC

Diesel Codegen Syntex

Provides the functionality of diesel_codegen using Syntex for usage on stable.

Getting started

Add diesel_codegen_syntex to your Cargo.toml, specifying which backends you use.

diesel_codegen_syntex = { version = "0.9.0", features = ["postgres"] }

Next, move the mod declarations of any modules that need codegen to a separate file, such as lib.in.rs, like so:

// main.in.rs
mod schema;
mod models;
// main.rs
include!(concat!(env!("OUT_DIR"), "/main.rs"));

Finally, add a build file which calls diesel_codgen_syntex::expand

// build.rs
fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let src = Path::new("src/main.in.rs");
    let dst = Path::new(&out_dir).join("main.rs");
    diesel_codegen_syntex::expand(&src, &dst).unwrap();
}

For more examples, please see section 4 of the getting started guide

Dependencies

~2.3–6MB
~117K SLoC