# Extension points — diesel-rs/diesel

> Canonical page: https://codevetter.com/unpack/diesel/extension-points

# Extension points — diesel-rs/diesel

Scanned commit 5cdf54e1434b87084a4630c100249f1028f3e32d (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

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. — [diesel/src/backend.rs#L30-L60](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/backend.rs#L30-L60) [diesel/src/backend.rs#L84-L113](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/backend.rs#L84-L113)
- 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. — [diesel/src/connection/mod.rs#L202-L245](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/connection/mod.rs#L202-L245)
- 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. — [diesel/src/query_builder/mod.rs#L241-L271](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/query_builder/mod.rs#L241-L271) [diesel/src/query_dsl/load_dsl.rs#L42-L49](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/query_dsl/load_dsl.rs#L42-L49) [diesel/src/query_dsl/load_dsl.rs#L91-L98](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/query_dsl/load_dsl.rs#L91-L98)
- 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. — [examples/postgres/custom_types/src/model.rs#L7-L35](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/examples/postgres/custom_types/src/model.rs#L7-L35)
- 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. — [diesel/src/connection/instrumentation.rs#L249-L264](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/connection/instrumentation.rs#L249-L264) [diesel/src/connection/instrumentation.rs#L269-L299](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/connection/instrumentation.rs#L269-L299) [diesel/src/pg/connection/mod.rs#L235-L240](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/pg/connection/mod.rs#L235-L240) [diesel_cli/src/database.rs#L199-L207](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/database.rs#L199-L207)
- Migration extensions implement Migration, MigrationMetadata, and MigrationSource; RustMigrationSource additionally registers callbacks, functions, RustMigration values, or custom TypedMigration implementations. — [diesel/src/migration/mod.rs#L99-L144](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel/src/migration/mod.rs#L99-L144) [diesel_migrations/src/rust_migrations.rs#L10-L29](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_migrations/src/rust_migrations.rs#L10-L29)
- CLI additions enter DieselCliCommand or MigrationCommand and their dispatch matches; schema customization enters PrintSchema configuration and the Config::read/update path. — [diesel_cli/src/cli.rs#L55-L79](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/cli.rs#L55-L79) [diesel_cli/src/main.rs#L81-L107](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/main.rs#L81-L107) [diesel_cli/src/migrations/mod.rs#L241-L272](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/migrations/mod.rs#L241-L272) [diesel_cli/src/config.rs#L488-L523](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/config.rs#L488-L523)
- 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. — [diesel_infer_query/src/lib.rs#L18-L22](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_infer_query/src/lib.rs#L18-L22) [diesel_cli/src/infer_schema_internals/schema_resolver.rs#L109-L127](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_cli/src/infer_schema_internals/schema_resolver.rs#L109-L127) [diesel_derives/src/lib.rs#L1506-L1508](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_derives/src/lib.rs#L1506-L1508) [diesel_derives/src/lib.rs#L1596-L1609](https://github.com/diesel-rs/diesel/blob/5cdf54e1434b87084a4630c100249f1028f3e32d/diesel_derives/src/lib.rs#L1596-L1609)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
