CodeVetter · Repo Unpack · Feature catalog
diesel-rs/diesel
Diesel's primary interface is a Rust API for composing and executing queries against typed schemas. The CLI adds database setup, migration lifecycle commands, schema generation, and shell completions. Supporting libraries offer runtime schema names, custom type conversion, and several migration sources. Examples demonstrate associations, authenticated blog operations, and embedded SQLite.
- Query composition includes filtering, selection, ordering, limits, and association-based subqueries; construction remains separate from load execution.
- The DSL exports insert_into, update, delete, insert_or_ignore_into, replace_into, select, and sql_query; execute returns affected-row counts, while get_result returns the first row or Error::NotFound.
- Associations support belonging_to and grouped_by, while joins support related and nullable records; the PostgreSQL relations example demonstrates one-to-many and many-to-many traversal.
- CLI commands are migration, setup, database/db, completions, and print-schema; migration dispatch implements run, revert, redo, list, pending, and generate.
- Schema configuration supports documentation, table filters, column order, schema namespaces, patches, imported/custom types, Rust enums, views, and experimental view-nullability inference.
- Migration generation can compare a Rust schema with the live database to produce up/down SQL; migration libraries additionally support filesystem SQL, embedded SQL, and Rust callbacks or TypedMigration implementations.
- diesel_dynamic_schema constructs tables and columns at runtime with explicit selections; custom Rust values can implement ToSql and FromSql, as illustrated by the Language enum.
- The advanced blog example offers paginated posts/comments, registration, post creation/editing/publishing, and comment creation/editing; the embedded SQLite example repeatedly queries both static and dynamic schemas.