sqly [github.com](https://github.com/LMOORS30/sqly) [crates.io](https://crates.io/crates/sqly) [docs.rs](https://docs.rs/sqly) ==== sqly is a lightweight macro system on top of [sqlx](https://github.com/launchbadge/sqlx), inspired by [ormx](https://github.com/NyxCode/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](#roadmap)).

##### Cargo.toml ```toml [dependencies.sqly] version = "0.3.0" features = ["postgres"] [dependencies.sqlx] version = "0.8.0" default-features = false features = ["postgres", "macros"] [profile.dev.package.sqlx-macros] opt-level = 3 [profile.dev.package.sqly-macros] opt-level = 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 [docs.rs](https://docs.rs/sqly)
### Roadmap **Major** - [x] Basic `DELETE` queries - [x] Basic `INSERT` queries - [x] Basic `UPDATE` queries - [X] Basic `SELECT` queries - [X] Storing information across separate `#[derive]` invocations - [ ] Optional outer macro pattern for better compiler support - [X] `#[sqly(foreign)]` - [X] SQL `INNER JOIN` - [X] SQL `LEFT JOIN` - [X] Custom SQL joins - [X] Unique table aliases - [ ] `sqly::query!` macros to extend generated queries **Minor** - [X] `Table::Flat` type for convenience - [ ] `#[derive(Flat)]` and `#[sqly(flat)]` for flexibility - [X] `#[sqly(infer)]` for custom sqlx types - [X] `#[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 SQL `RETURNING` clause - [ ] `#[sqly(distinct)]` for SQL `DISTINCT` clause - [ ] `#[sqly(from, try_from, default)]` for table - [ ] Implementation of bulk operations for `&[T]` **Draft** - [ ] `#[sqly(group)]` for SQL `GROUP BY` clause - [ ] Decoding database rows unchecked or by index - [ ] Custom macro attributes in generated structs - [ ] Support for generic structs - [ ] ... ?
#### License Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.