# Data flow — SeaQL/sea-orm

> Canonical page: https://codevetter.com/unpack/sea-orm/data-flow

# Data flow — SeaQL/sea-orm

Scanned commit db40a19a7bde7be8e1c4b346b1b70d72e87f0245 (2026-09-27). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Typed entity metadata becomes SeaQuery statements, then backend SQL and bound values, then driver results decoded into models. Connections own database handles, while selectors and ActiveModels own query and mutation state. Tooling follows separate pipelines from live schema to generated files and from migration definitions to recorded database versions.
- Database::connect converts its input into ConnectOptions, validates the URL, dispatches by enabled backend prefix, and returns a connection error when parsing or driver selection fails. — [src/database/mod.rs#L173-L214](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/database/mod.rs#L173-L214)
- ConnectionTrait::execute/query_one/query_all lower StatementBuilder inputs through DbBackend::build; PostgreSQL sqlx_query passes Statement.sql and its Values separately to sqlx::query_with. — [src/database/connection.rs#L25-L52](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/database/connection.rs#L25-L52) [src/driver/sqlx_postgres.rs#L346-L351](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/driver/sqlx_postgres.rs#L346-L351)
- Selector::one adds LIMIT 1 and decodes an optional QueryResult; Selector::all decodes every returned row through SelectorTrait::from_raw_query_result, propagating conversion errors. — [src/executor/select.rs#L868-L903](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/executor/select.rs#L868-L903)
- ActiveValue state controls writes: Set carries values to persist, Unchanged is omitted from UPDATE, and NotSet is omitted from INSERT and UPDATE; save selects insertion or update based on whether all primary-key columns are present. — [src/entity/active_model.rs#L15-L29](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/entity/active_model.rs#L15-L29) [src/entity/active_model.rs#L375-L403](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/entity/active_model.rs#L375-L403)
- ActiveModel::from_json merges defaults for deserialization, tracks which JSON keys were supplied, and converts absent fields to NotSet; set_from_json backs up and restores primary-key values around replacement. — [src/entity/active_model.rs#L460-L490](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/entity/active_model.rs#L460-L490) [src/entity/active_model.rs#L504-L551](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/entity/active_model.rs#L504-L551)
- Schema discovery filters selected, hidden, ignored, and generated columns before producing table statements; EntityTransformer builds columns, primary keys, enums, and relations, pruning references to tables outside the selected set. — [sea-orm-cli/src/commands/generate.rs#L256-L285](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-cli/src/commands/generate.rs#L256-L285) [sea-orm-cli/src/commands/generate.rs#L299-L325](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-cli/src/commands/generate.rs#L299-L325) [sea-orm-codegen/src/entity/transformer.rs#L25-L61](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-codegen/src/entity/transformer.rs#L25-L61) [sea-orm-codegen/src/entity/transformer.rs#L199-L207](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-codegen/src/entity/transformer.rs#L199-L207)
- Migration status compares registered migration names with stored seaql_migrations versions; applying a migration records its name and timestamp, while rollback removes its version record. — [sea-orm-migration/src/migrator/exec.rs#L52-L85](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-migration/src/migrator/exec.rs#L52-L85) [sea-orm-migration/src/migrator/exec.rs#L207-L238](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-migration/src/migrator/exec.rs#L207-L238) [sea-orm-migration/src/migrator/exec.rs#L267-L282](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-migration/src/migrator/exec.rs#L267-L282) [sea-orm-migration/src/migrator/exec.rs#L313-L328](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/sea-orm-migration/src/migrator/exec.rs#L313-L328)
- RestrictedConnection routes structured statements through an audit that yields action/schema/table requests; RbacEngineMount reads its shared engine and requires every request to be permitted before forwarding execution. — [src/database/restricted_connection.rs#L60-L90](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/database/restricted_connection.rs#L60-L90) [src/database/restricted_connection.rs#L526-L557](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/database/restricted_connection.rs#L526-L557) [src/rbac/engine/mod.rs#L274-L335](https://github.com/SeaQL/sea-orm/blob/db40a19a7bde7be8e1c4b346b1b70d72e87f0245/src/rbac/engine/mod.rs#L274-L335)

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)
