sqly 0.5.0

A lightweight macro system on top of sqlx
Documentation

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 by the added functionality of generating SQL SELECT queries with support for nested objects through SQL JOIN clauses. Additionally, many more attributes are available to further customize the query generation and row decoding.

Cargo.toml
[dependencies.sqly]
version = "0.5.0"
features = ["postgres"]

[dependencies.sqlx]
version = "0.8.6"
default-features = false

[profile.dev.package.sqlx-macros]
opt-level = 3

[profile.dev.package.sqly-macros]
opt-level = 3
Features

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) checked — enable compile-time checking (default)

Currently only postgres is supported.

Usage

Roadmap

Major

  • Basic DELETE queries
  • Basic INSERT queries
  • Basic UPDATE queries
  • Basic SELECT queries
    • Storing information across separate #[derive] invocations
    • Optional outer macro pattern for better compiler support
  • #[sqly(foreign)]
    • SQL INNER JOIN
    • SQL LEFT JOIN
    • Custom SQL joins
    • Unique table aliases
  • sqly::query! macros to extend generated queries

Minor

  • Flat::Flat type for flexibility
  • #[sqly(infer)] for custom sqlx types
  • #[sqly(value)] for custom parameter binding
  • #[sqly(select)] for custom SQL select expressions
  • #[sqly(default, from, try_from)] for decoding table fields
  • #[sqly(insert, update)] for custom SQL value expressions
  • #[sqly(filter)] for custom SQL filter expressions
  • #[sqly(optional)] for dynamic SQL through optional fields
  • #[sqly(returning)] for SQL RETURNING clause

Draft

  • #[sqly(flatten)] for nested structs
  • #[sqly(group)] for SQL GROUP BY clause
  • #[sqly(distinct, order, limit, offset)] clauses
  • Decoding database rows unchecked or by index
  • Custom attributes in generated structs
  • Support for generic structs
  • Output dummy code on error
  • ... ?

License