IMPORTANT - 0.0.x versions will be experimental and probably break APIs in each release.

sqlb is (will be) a simple and expressive SQLBuilder for Rust.

NOTE: SQL Builders are typically not used directly by application business logic, but rather to be wrapped in some Application Data Access Layer (e.g., DAOs or MACs - Model Access Controller -). In fact, even when using ORMs, it is often a good code design to wrap those access via some data access layers.

Goals for first 0.1.x releases:

Early API Example (just conceptual for now)

```rust

[derive(sqlx::FromRow)] // Optional: to be able to use the sqlxexec::fetchas...

pub struct Todo { pub id: i64, pub title: String, }

[derive(sqlb::Fields)] // implements sqlb::HasFields for dynamic binding

pub struct TodoPatch { pub title: Option, }

let patchdata = TodoPatch { title: Some("Hello Title".tostring()) };

// INSERT - Insert a new Todo from a Partial todo let sb = sqlb::insert().table("todo").data(patchdata.fields()); let sb = sb.returning(&["id", "title"]); let (id, title) = sb.fetchone::<(i64, String), _>(&dbpool).await?;

// SELECT - Get all todos let sb = sqlb::select().table("todo").columns(&["id", "title"]).orderby("!id"); let todos: Vec = sb.fetchasall(&dbpool).await?; assert_eq!(1, todos.len()); ```

Latest Breaking Changes

For sqlb Dev

Start a PostgreSQL

```sh

In terminal 1 - start postges

docker run --rm --name pg -p 5432:5432 -e POSTGRES_PASSWORD=welcome postgres:14

In terminal 2 - (optional) launch psql on the Postgres instance above

docker exec -it -u postgres pg psql

In terminal 3 - MUST run with --test-threads=1 to avoid database access conflicts

cargo test -- --test-threads=1

or watch a particular test target

cargo watch -q -c -x 'test --test testsbinsert -- --test-threads=1' ```