sqly
sqly is a lightweight macro system on top of sqlx, inspired by ormx.
It works by generating common SQL queries and associated structs at compile time, letting the generated queries be checked and executed by sqlx.
This crate differs from ormx mainly by the added functionality of generating SQL SELECT queries with support for nested objects through SQL JOIN clauses. Additionally, sqly::query! macros can be used to further expand generated queries while still providing compile-time verification.
This functionality is still under development (see Roadmap).
Cargo.toml
[]
= "0.3.0"
= ["postgres"]
[]
= "0.8.0"
= false
= ["postgres", "macros"]
[]
= 3
[]
= 3
Features
unchecked — disable compile-time checking
postgres — generate queries for PostgreSQL
mariadb — generate queries for MariaDB (not supported)
sqlite — generate queries for SQLite (not supported)
mysql — generate queries for MySQL (not supported)
Currently only postgres is supported.
Usage
Roadmap
Major
- Basic
DELETEqueries - Basic
INSERTqueries - Basic
UPDATEqueries - Basic
SELECTqueries- Storing information across separate
#[derive]invocations - Optional outer macro pattern for better compiler support
- Storing information across separate
-
#[sqly(foreign)]- SQL
INNER JOIN - SQL
LEFT JOIN - Custom SQL joins
- Unique table aliases
- SQL
-
sqly::query!macros to extend generated queries
Minor
-
Table::Flattype for convenience-
#[derive(Flat)]and#[sqly(flat)]for flexibility
-
-
#[sqly(infer)]for custom sqlx types -
#[sqly(value)]for custom parameter binding -
#[sqly(select)]for custom SQL select expressions -
#[sqly(filter)]for custom SQL filter expressions -
#[sqly(optional)]for optional update and insert fields -
#[sqly(returning)]for SQLRETURNINGclause -
#[sqly(distinct)]for SQLDISTINCTclause -
#[sqly(from, try_from, default)]for table - Implementation of bulk operations for
&[T]
Draft
-
#[sqly(group)]for SQLGROUP BYclause - Decoding database rows unchecked or by index
- Custom macro attributes in generated structs
- Support for generic structs
- ... ?