SeaORM v2.0.0-rc.38 Release Notes

Release Date: 2026-04-09 // about 2 months ago
  • ๐Ÿš€ Release Notes: SeaORM 2.0.0-rc.38

    (since 2.0.0-rc.37)

    ๐Ÿ†• New Features

    find_both_related() โ€” required inner join loader (#2997)

    A new find_both_related() method returns Vec<(E::Model, F::Model)> (both sides non-optional), as a counterpart to the existing find_also_related() which returns Vec<(E::Model, Option<F::Model>)>. Use this when you know the relation is always populated and want to avoid the Option unwrap:

    letresults:Vec\<(Order,LineItem)\>=Order::find().find\_both\_related(LineItem).all(db).await?;
    

    set_ne / set_ne_and aliases on ActiveValue (#3040)

    Shorter aliases for set_if_not_equals and set_if_not_equals_and. The long-form names are kept as compatibility aliases:

    // Beforeactive_model.name.set\_if\_not\_equals("Alice");// Afteractive_model.name.set\_ne("Alice");
    

    map_sqlx_*_pool_opts on ConnectOptions (#2770)

    Three new methods to customise the underlying sqlx::pool::PoolOptions before the connection pool is created โ€” one per driver:

    ConnectOptions::new(DATABASE\_URL).map\_sqlx\_postgres\_pool\_opts(|opts| opts.max\_connections(20).min\_connections(5)).to\_owned()
    

    ๐Ÿ‘ BTreeMap / HashMap support in TryGetableFromJson (#3009)

    Map types can now be used directly as model fields when the column holds a JSON object:

    pubstructModel{pubid:i32,pubmetadata:HashMap\<String,serde_json::Value\>,}
    

    Inherited visibility in derive macros (#3029)

    DeriveEntityModel, DeriveActiveModel, DeriveModel, and related macros now inherit the pub(crate) / pub(super) / private visibility of the struct they are applied to, instead of always emitting pub items.

    ๐Ÿ› Bug Fixes

    ๐Ÿ”€ Schema sync: drop unique constraint on PostgreSQL (#2994)

    ๐Ÿ”€ DROP INDEX fails on PostgreSQL for unique indexes created via column-level UNIQUE because they are backed by a named constraint, not a standalone index. Schema sync now uses ALTER TABLE โ€ฆ DROP CONSTRAINT on PostgreSQL and falls back to DROP INDEX on other backends.

    ๐Ÿ”€ Schema sync: tables in non-default schemas now discovered (#3016)

    sync() previously ran schema discovery only against CURRENT_SCHEMA(). Entities with #[sea_orm(schema_name = "other")] were never found, causing every sync to attempt a redundant CREATE TABLE. Discovery now collects all schemas referenced by registered entities and queries each one.

    Nested PartialModel null detection for optional fields (#3039)

    A nested Option<PartialModel> loaded via a left join could incorrectly fail with Missing value for column 'id' when the nested model itself contained Option<T> fields. The null check now correctly handles arbitrary Option nesting depth.

    use_transaction per-migration config was ignored (#3002)

    exec_with_connection unconditionally wrapped all PostgreSQL migration operations in a transaction, overriding the per-migration use_transaction setting. The macro has been removed and each call site now uses the correct connection type.

    Proc macros failed on long type paths with newlines (#3031)

    DeriveActiveModelEx and other derive macros used .replace(' ', "") to strip whitespace, which missed newlines in formatted type paths longer than ~50 characters. Replaced with .split_whitespace().collect().

    TIMESTAMPTZ conversion in the Postgres proxy driver (#3004)

    from_sqlx_postgres_row_to_proxy_row now correctly converts TIMESTAMPTZ columns, fixing a panic when using the proxy driver with timestamptz fields.

    โšก๏ธ Dependency Updates

    • โšก๏ธ arrow updated to 58 (#3007)
    • โšก๏ธ strum updated to 0.28 (#2993)

Previous changes from v2.0.0-rc.37

  • ๐Ÿ†• New Features

    ER Diagram Generation (sea-orm-cli generate entity --er-diagram)

    sea-orm-cli can now generate a Mermaid ER diagram alongside the entity files. Pass --er-diagram to write entities.mermaid into the output directory:

    sea-orm-cli generate entity -u postgres://... -o src/entity --er-diagram
    

    The diagram annotates columns with PK, FK, and UK markers and renders all relations โ€” including many-to-many via junction tables โ€” as Mermaid erDiagram syntax. Example output:

    image

    โฑ PostgreSQL Statement Timeout (ConnectOptions::statement_timeout)

    โฑ ConnectOptions now accepts a statement_timeout for PostgreSQL connections. The timeout is set via the connection options at connect time (no extra round-trip) and causes the server to abort any statement that exceeds the duration:

    ConnectOptions::new(DATABASE\_URL).statement\_timeout(Duration::from\_secs(30)).to\_owned()
    

    Has no effect on MySQL or SQLite connections.

    ๐Ÿ‘ SQLite ?mode= URL Parameter Support (#2987)

    ๐Ÿ“œ The rusqlite driver now parses the ?mode= query parameter from SQLite connection URLs, matching the behaviour of the sqlx SQLite driver:

    Mode Behaviour
    0๏ธโƒฃ rwc (default)
    rw Read-write, must exist
    ro Read-only
    memory In-memory database
    // Open an existing database read-onlyletdb =Database::connect("sqlite:./data.db?mode=ro").await?;
    

    ๐Ÿ‘ Unsupported parameters or unknown mode values return a DbErr::Conn error.

    ๐Ÿ› Bug Fixes

    0๏ธโƒฃ no-default-features compile errors with mac_address and proxy (#2992)

    • โž• with-mac_address feature: added missing TryGetable impls, try_from_u64 impl, postgres array support, and with-json serde flag
    • ๐Ÿšš proxy feature: removed an accidental hard dependency on serde_json (now only activated via with-json)
    • ๐Ÿ›  Fixed cfg guards on JSON/JSONB proxy row handling to require with-json