CodeVetter · Repo Unpack · Extension points
diesel-rs/diesel
Extensions primarily enter through Rust traits, procedural macros, configuration fields, and explicit CLI dispatch. Backend support separates dialect metadata from connection implementation. Applications can add custom value conversion, query fragments, instrumentation, and migration sources. Internal extension interfaces sometimes require an explicit feature acknowledging compatibility risk.
- Custom Backend implementations supply QueryBuilder, RawValue, BindCollector, SqlDialect, TypeMetadata, and SQL-type mappings; access requires the third-party-backend opt-in feature.
- Custom connections implement Connection with backend and transaction-manager ownership; the documentation also calls for backend-specific FromSql/ToSql conversions and gates implementations through ConnectionSealed.
- New query AST nodes implement QueryFragment::walk_ast, which supplies SQL-generation and other AST-pass behavior; execution/loading requires appropriate QueryFragment and QueryId implementations.
- Custom SQL value types implement ToSql and FromSql and derive expression/row support; the Language example serializes enum variants as PostgreSQL bytes and rejects unknown variants during decoding.
- Instrumentation extensions implement on_connection_event or use a closure, can be installed per connection, and can register a global constructor for future connections when std is enabled.
- Migration extensions implement Migration, MigrationMetadata, and MigrationSource; RustMigrationSource additionally registers callbacks, functions, RustMigration values, or custom TypedMigration implementations.
- CLI additions enter DieselCliCommand or MigrationCommand and their dispatch matches; schema customization enters PrintSchema configuration and the Config::read/update path.
- SchemaResolver is exported for SQL/view inference, and SchemaResolverImpl adapts CLI catalog metadata to it; table_proc routes table macro expansion into query_source_macro, while view declarations use the corresponding generated schema model.