typed-sql

Crates.iotyped-sql
lib.rstyped-sql
version0.2.1
sourcesrc
created_at2021-05-23 16:45:22.624759
updated_at2023-07-15 19:15:40.761694
descriptionA strongly typed sql serialization/deserialization framework
homepage
repositoryhttps://github.com/matthunz/typed-sql
max_upload_size
id401161
size40,254
Matt Hunzinger (matthunz)

documentation

README

typed-sql

Latest Version Rust Documentation LICENSE

use typed_sql::{Query, Table, ToSql};

#[derive(Table)]
struct User {
    id: i64,
    name: String
}

let stmt = User::table()
    .select()
    .filter(|user| user.id.neq(6).and(user.id.gt(3)))
    .group_by(|user| user.name)
    .order_by(|user| user.name.then(user.id.ascending()))
    .limit(5);

assert_eq!(
    stmt.to_sql(),
    "SELECT * FROM users \
    WHERE users.id != 6 AND users.id > 3 \
    GROUP BY users.name \
    ORDER BY users.name,users.id ASC \
    LIMIT 5;"
);
Commit count: 38

cargo fmt