๐Ÿš An async & dynamic ORM for Rust

Overview

SeaORM

๐Ÿš An async & dynamic ORM for Rust

crate docs build status

SeaORM

SeaORM is a relational ORM to help you build web services in Rust with the familiarity of dynamic languages.

Getting Started

Discord Join our Discord server to chat with others in the SeaQL community!

Features

  1. Async

    Relying on SQLx, SeaORM is a new library with async support from day 1.

  2. Dynamic

    Built upon SeaQuery, SeaORM allows you to build complex queries without 'fighting the ORM'.

  3. Testable

    Use mock connections to write unit tests for your logic.

  4. Service Oriented

    Quickly build services that join, filter, sort and paginate data in APIs.

A quick taste of SeaORM

Entity

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub name: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::fruit::Entity")]
    Fruit,
}

impl Related<super::fruit::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::Fruit.def()
    }
}

Select

// find all models
let cakes: Vec<cake::Model> = Cake::find().all(db).await?;

// find and filter
let chocolate: Vec<cake::Model> = Cake::find()
    .filter(cake::Column::Name.contains("chocolate"))
    .all(db)
    .await?;

// find one model
let cheese: Option<cake::Model> = Cake::find_by_id(1).one(db).await?;
let cheese: cake::Model = cheese.unwrap();

// find related models (lazy)
let fruits: Vec<fruit::Model> = cheese.find_related(Fruit).all(db).await?;

// find related models (eager)
let cake_with_fruits: Vec<(cake::Model, Vec<fruit::Model>)> =
    Cake::find().find_with_related(Fruit).all(db).await?;

Insert

let apple = fruit::ActiveModel {
    name: Set("Apple".to_owned()),
    ..Default::default() // no need to set primary key
};

let pear = fruit::ActiveModel {
    name: Set("Pear".to_owned()),
    ..Default::default()
};

// insert one
let pear = pear.insert(db).await?;

// insert many
Fruit::insert_many(vec![apple, pear]).exec(db).await?;

Update

use sea_orm::sea_query::{Expr, Value};

let pear: Option<fruit::Model> = Fruit::find_by_id(1).one(db).await?;
let mut pear: fruit::ActiveModel = pear.unwrap().into();

pear.name = Set("Sweet pear".to_owned());

// update one
let pear: fruit::ActiveModel = pear.update(db).await?;

// update many: UPDATE "fruit" SET "cake_id" = NULL WHERE "fruit"."name" LIKE '%Apple%'
Fruit::update_many()
    .col_expr(fruit::Column::CakeId, Expr::value(Value::Int(None)))
    .filter(fruit::Column::Name.contains("Apple"))
    .exec(db)
    .await?;

Save

let banana = fruit::ActiveModel {
    id: Unset(None),
    name: Set("Banana".to_owned()),
    ..Default::default()
};

// create, because primary key `id` is `Unset`
let mut banana = banana.save(db).await?;

banana.name = Set("Banana Mongo".to_owned());

// update, because primary key `id` is `Set`
let banana = banana.save(db).await?;

Delete

let orange: Option<fruit::Model> = Fruit::find_by_id(1).one(db).await?;
let orange: fruit::ActiveModel = orange.unwrap().into();

// delete one
fruit::Entity::delete(orange).exec(db).await?;
// or simply
orange.delete(db).await?;

// delete many: DELETE FROM "fruit" WHERE "fruit"."name" LIKE 'Orange'
fruit::Entity::delete_many()
    .filter(fruit::Column::Name.contains("Orange"))
    .exec(db)
    .await?;

Learn More

  1. Design
  2. Architecture
  3. Release Model
  4. Change Log

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Compact Entity format

    Compact Entity format

    I was trying your crate, seems promising, but the way you choose to represent models is too verbose. For example I've a DB table with 53 fields, using your system I've written like 210 LOC, repeating the same informations like 3 times.

    I think everything could be done with a single proc_macro, that takes a standard Rust struct and replaces it with a module with the same name of the struct, with Model struct with more or less the same contents of the original struct, Column enum with structs fields as variants, automatic impl ColumnTrait for Column with a type mapping, where the mapping fails you can use a field notation to override it (comes handy for custom types), table name and primary key can be specified with a struct notation, what's missing? Relations, well, this have to be specified externally, but you can point the enum with another notation, and if the notation isn't present you generate a void enum.

    After that, if I can add something more, I often use Cow on my entities, because this way I'm not forced to clone Strings when updating/creating. With your system I can't, because Model doesn't support a lifetime. It's not a big problem, but it blocks also other custom types with a lifetime

    opened by nappa85 64
  • Entity Generator

    Entity Generator

    Generating entity file for each db table.

    • Entity
    • Model
      • mapping db column type to Rust type
      • find_* helper function
    • Column
      • ColumnTrait column def
    • PrimaryKey
    • Relation
      • RelationTrait relation def
    • Related

    Work plan in progress...

    use crate as sea_orm;
    use crate::entity::prelude::*;
    
    #[derive(Copy, Clone, Default, Debug, DeriveEntity)]
    #[table = "cake"]
    pub struct Entity;
    
    #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
    pub struct Model {
        pub id: i32,
        pub name: String,
    }
    
    #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
    pub enum Column {
        Id,
        Name,
    }
    
    #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
    pub enum PrimaryKey {
        Id,
    }
    
    #[derive(Copy, Clone, Debug, EnumIter)]
    pub enum Relation {
        Fruit,
    }
    
    impl ColumnTrait for Column {
        type EntityName = Entity;
    
        fn def(&self) -> ColumnType {
            match self {
                Self::Id => ColumnType::Integer(None),
                Self::Name => ColumnType::String(None),
            }
        }
    }
    
    impl RelationTrait for Relation {
        fn def(&self) -> RelationDef {
            match self {
                Self::Fruit => Entity::has_many(super::fruit::Entity)
                    .from(Column::Id)
                    .to(super::fruit::Column::CakeId)
                    .into(),
            }
        }
    }
    
    impl Related<super::fruit::Entity> for Entity {
        fn to() -> RelationDef {
            Relation::Fruit.def()
        }
    }
    
    impl Related<super::filling::Entity> for Entity {
        fn to() -> RelationDef {
            super::cake_filling::Relation::Filling.def()
        }
    
        fn via() -> Option<RelationDef> {
            Some(super::cake_filling::Relation::Cake.def().rev())
        }
    }
    
    impl Model {
        pub fn find_fruit(&self) -> Select<super::fruit::Entity> {
            Entity::find_related().belongs_to::<Entity>(self)
        }
    
        pub fn find_filling(&self) -> Select<super::filling::Entity> {
            Entity::find_related().belongs_to::<Entity>(self)
        }
    }
    
    opened by billy1624 58
  • How to downgrade sea-orm-cli version?

    How to downgrade sea-orm-cli version?

    If I install with:

    cargo install [email protected]
    

    and generate with:

    sea-orm-cli generate entity //......
    

    the generated file have:

    //! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.5
    

    instead of of 0.10.2.

    If I run

    sea-orm-cli -v
    

    I can see:

    sea-orm-cli 0.10.2
    

    What is going on?

    I need the 0.10.2 version right now.

    opened by frederikhors 29
  • Transaction 2

    Transaction 2

    #142

    This is a HUGE rework of Transactions, that permits nested transactions, streams in transactions, etc... There is unsafe code, not much, should be safe, but needs a lot of testing. To avoid unsafe code we'll probably need a design rework. This PR is based on the streams one, probably will be a mess of conflicts, I just need to know what you think about and decide how to go on

    opened by nappa85 29
  • Pagination API

    Pagination API

    A new struct Paginator that wraps a Select, that would:

    1. lazily COUNT the total number of records and number of pages
    2. perform paging by LIMIT and OFFSET

    A helper method to convert a select into a paginator: (something like)

    fn paginate(page_size: i32) -> Paginator<T>
    

    The Paginator should impl the Stream trait.

    Ref: https://docs.rs/futures-core/0.3.15/futures_core/stream/trait.Stream.html https://tokio.rs/tokio/tutorial/streams https://docs.rs/async-std/1.9.0/async_std/stream/trait.Stream.html

    opened by tyt2y3 27
  • sea-orm-cli migrate doesn't respect DATABASE_SCHEMA in .env file

    sea-orm-cli migrate doesn't respect DATABASE_SCHEMA in .env file

    Description

    Running the command:

    sea-orm-cli migrate ...
    

    Always runs migrations against the public schema in PostgreSQL rather than the schema specified in .env

    Steps to Reproduce

    1. Create .env file with DATABASE_SCHEMA=not_public
    2. Run sea-orm-cli migrate...

    Expected Behavior

    Migrations are run in specified schema

    Actual Behavior

    See that all migrations were run in public schema

    Versions

    โ””โ”€โ”€ sea-orm v0.6.0
        โ”œโ”€โ”€ sea-orm-macros v0.6.0 (proc-macro)
        โ”œโ”€โ”€ sea-query v0.21.0
        โ”‚   โ”œโ”€โ”€ sea-query-derive v0.2.0 (proc-macro)
        โ”œโ”€โ”€ sea-strum v0.23.0
        โ”‚   โ””โ”€โ”€ sea-strum_macros v0.23.0 (proc-macro)
    โ””โ”€โ”€ sea-schema v0.5.1
        โ”œโ”€โ”€ sea-orm v0.6.0 (*)
        โ”œโ”€โ”€ sea-query v0.21.0 (*)
        โ”œโ”€โ”€ sea-schema-derive v0.1.0 (proc-macro)
    
    good first issue 
    opened by MattGson 18
  • CockroachDB support

    CockroachDB support

    Sqlx has a known issue with transations and MARS https://github.com/launchbadge/sqlx/issues/933

    Does sea orm has a workaround to do multiple inserts inside single transaction with CockroachDB?

    tokio-postgres has no problems, so it might be fixed on client side somehow without waiting for https://github.com/cockroachdb/cockroach/issues/40195

    opened by sergeyshaykhullin 17
  • How can auto migrate table struct when application startup?

    How can auto migrate table struct when application startup?

    I used sea-orm and sqlite for desktop application save preferences. I need auto modify columns and index when app upgrade (app startup).

    Does sea-orm have this function ?

    like this

    Cake::auto_migrate(db).await?;
    
    #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
    #[sea_orm(table_name = "cake")]
    pub struct Model {
        #[sea_orm(primary_key)]
        pub id: i32,
        pub name: String,
        pub content: String, // <--- add this line , table auto add column
    }
    

    auto migrate index

    pub struct Model {
        #[sea_orm(primary_key)]
        pub id: i32,
        #[sea_orm(index="idx_name_content")]
        pub name: String,
        #[sea_orm(index="idx_name_content")]
        pub content: String,
        #[sea_orm(unique="uk_uuid")]
        pub demo_uuid: String,
    }
    
    opened by niuhuan 17
  • Introduce optional serde support for model code generation

    Introduce optional serde support for model code generation

    This introduces several things to optionally support automatic derive attributes for serde::{Deserialize, Serialize} for the generated models:

    • introduces a feature flag for sea-orm-codegen which optionally includes the serde dependency (can be activated via cargo build / install --features with-serde),
    • introduces a WithSerde enum to indicate if Serialize, Deserialize, or even both should be derived from,
    • introduces a feature flag for sea-orm-cli which optionally activates the sea-orm-codegen feature flag with-serde (can also be activated via cargo build / install --features with-serde),
    • adds an optional cli argument --with-serde [none: default, serialize, deserialize, both]
    • adds test harness for both compact and expanded generation

    Potential TODOs:

    • Add conditional compilation for the cli argument --with-serde
    • Make it more beautiful, but I wanted to wait for the first signal if this is the right direction to go for...

    This PR is related to #236

    opened by elbart 17
  • Allow creating a sea_orm::Databse from sqlx::ConnectOptions

    Allow creating a sea_orm::Databse from sqlx::ConnectOptions

    Seems like doing what is requested in #398 is too difficult.

    However allowing users to create a sea_orm::Database from sqlx::ConnectOptions implementations like MySqlConnectOptions seems to be doable.

    For me this is good enough.

    Also I have added a new feature options sqlx-any. If this is enabled the sqlx is any feature is turned on and you can create an sea_orm::Database from AnyConnectOptions as well.

    ~However this depends on this PR https://github.com/launchbadge/sqlx/pull/1610 (not yet merged!)~ MERGED and released

    opened by 05storm26 16
  • Trait conflict when implementing `IntoActiveModel<A>` outside of entity model definition

    Trait conflict when implementing `IntoActiveModel` outside of entity model definition

    Description

    Trying to implement IntoActiveModel<A> outside of my entity model definition gives the following error:

      --> src/actions.rs:45:1
       |
    45 | impl IntoActiveModel<user_account::ActiveModel> for UpdateUser {
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: conflicting implementation in crate `entity`:
               - impl IntoActiveModel<entity::user_account::ActiveModel> for <entity::prelude::UserAccount as sea_orm::EntityTrait>::Model;
    
    

    I can't use DeriveIntoActiveModel either since I'm unaware how to specify (via attribute or etc) the specific ActiveModelTrait type that my type converts into since I define it outside of my crate.

    Steps to Reproduce

    // this is in entity::user_account::Model
    #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
    #[sea_orm(table_name = "user_account")]
    pub struct Model {
        #[sea_orm(primary_key, auto_increment = false)]
        pub id: Uuid,
        pub created_at: DateTimeWithTimeZone,
        pub updated_at: DateTimeWithTimeZone,
        #[sea_orm(column_type = "Text")]
        pub name: String,
        pub email: String,
        #[sea_orm(column_type = "Text")]
        pub password: String,
        pub verified: bool,
    }
    
    // this exists in a separate, main crate where I perform other logic
    #[derive(Debug)]
    pub(crate) struct UpdateUser {
        pub(crate) name: Option<String>,
        pub(crate) email: Option<String>
    }
    
    impl IntoActiveModel<user_account::ActiveModel> for UpdateUser {
        fn into_active_model(self) -> user_account::ActiveModel {
            user_account::ActiveModel {
                name: sea_orm::IntoActiveValue::<_>::into_active_value(self.name).into(),
                email: sea_orm::IntoActiveValue::<_>::into_active_value(self.email).into(),
                ..::std::default::Default::default()
            }
        }
    }
    

    Expected Behavior

    I expect it to be able to convert my type (defined outside of the entity crate) into an ActiveModel that I can use to update rows in my table.

    Actual Behavior

    Doesn't work as explained above.

    Reproduces How Often

    Always reproducible.

    Versions

    โฏ cargo tree | grep sea-
    โ”‚   โ”œโ”€โ”€ sea-orm v0.6.0
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-orm-macros v0.6.0 (proc-macro)
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-query v0.21.0
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ sea-query-derive v0.2.0 (proc-macro)
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-strum v0.23.0
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ sea-strum_macros v0.23.0 (proc-macro)
    โ”œโ”€โ”€ sea-orm v0.6.0 (*)
    

    Database is Postgres 13.5, OS is ArchLinux 5.16.9-zen1-1-zen

    Additional Information

    Might be related to #322, #323, #340.

    opened by fairingrey 15
  • Hitting 'negative last_insert_rowid' panic with Sqlite

    Hitting 'negative last_insert_rowid' panic with Sqlite

    Description

    I have a table with a primary ID that is a hash, stored as a signed integer (since unsigned 64 bit is not supported). Auto-increment is turned off for that table. When storing a new element, if the hash as signed is negative, then sea-orm panics on that line: https://github.com/SeaQL/sea-orm/blob/master/src/executor/execute.rs#L43

    Steps to Reproduce

    • Create an SQlite table with an i64 primary key: https://github.com/nitnelave/lldap/blob/c64d32e2c0cc698c61ca40e8364ab0cd7934cd46/server/src/domain/model/jwt_refresh_storage.rs#L12
    • Insert a negative value.

    Expected Behavior

    Since auto-increment is turned off for that table, last_insert_id should probably not be called to avoid a panic.

    Actual Behavior

    Panic.

    Reproduces How Often

    Always.

    Versions

    Using sea-orm 0.10.3 (no other version override). Running on alpine, using the bundled Sqlite.

    Additional Information

    The query, for reference: https://github.com/nitnelave/lldap/blob/c64d32e2c0cc698c61ca40e8364ab0cd7934cd46/server/src/infra/sql_backend_handler.rs#L49

    opened by nitnelave 1
  • First implementation of config for generate entity

    First implementation of config for generate entity

    PR Info

    • Closes #1185
    • Dependencies: merge = "0.1.0" serde = "1.0.152" serde_json = "1.0.91"
    • Dependents:

    New Features

    • [-] Add config parsing option and flag to the cli generate entity command

    Bug Fixes

    • [ ]

    Breaking Changes

    • [ ]

    Changes

    • [ ]
    opened by aadi58002 0
  • Derive macros for custom wrapper types

    Derive macros for custom wrapper types

    Right now, custom wrapper types kind of work with SeaORM, e.g. 1) https://github.com/SeaQL/sea-orm/blob/master/tests/common/features/event_trigger.rs 2) https://github.com/nitnelave/lldap/pull/382/files#diff-27e26a3b85b610666d7dd0a3fa3e848582ab2d3999f7b1bdfed61052f82af741R96-R168 but require a lot of boilerplate, it'd be nice if we can make a DeriveValueType macro and remove some entropy.

    To start, we can only accept struct in the form of struct MyType(pub T). It would be great if we can also accept Vec<T>, where I think Nullable can also be implemented.

    And may be a column_type attribute to allow customizing the column type.

    opened by tyt2y3 0
  • Call for Contributors and Reviewers

    Call for Contributors and Reviewers

    https://www.sea-ql.org/blog/2023-01-01-call-for-contributors-n-reviewers/

    The SeaORM userbase has been growing steadily. While we are happy to help individuals and start-ups to build their projects in Rust, the volume of questions, issues and pull requests is nearly saturating our capacity.

    You are invited to become a Contributor. Contributors can also participate in code reviews and become Reviewers.

    Let's make SeaORM better together!

    opened by tyt2y3 2
  • Add JsonBinary attribute

    Add JsonBinary attribute

    PR Info

    • This will close #1344

    Notes

    Currently, this only seems to work on compact entity structures. As of writing this, I'm unsure on how the attribute should be added in the expanded form, so I'll need some insights on that.

    TODO

    ~~- Get this to work on expanded entity structure~~

    • [x] Write tests
    opened by AngelOnFira 2
  • Generating entity from Postgres with `JsonBinary` field doesn't add attribute to model

    Generating entity from Postgres with `JsonBinary` field doesn't add attribute to model

    Description

    When generating entities from an existing Postgres database, Json Binary fields don't include the attribute #[sea_orm(column_type = "JsonBinary")].

    Steps to Reproduce

    This example will go through setting up a migration, running the migration, and then generating entities. This is all being done on a Postgres database.

    1. Create a table in a migration, say:
    manager
        .create_table(
            Table::create()
                .table(Task::Table)
                .if_not_exists()
                ...
                .col(ColumnDef::new(Task::Status).json_binary().not_null())
                .col(ColumnDef::new(Task::Payload).json_binary().not_null())
                .to_owned(),
        )
        .await
    

    When built, this generates the string

    CREATE TABLE IF NOT EXISTS \"task\" ( \"id\" serial NOT NULL PRIMARY KEY, \"status\" jsonb NOT NULL, \"payload\" jsonb NOT NULL )

    1. Run the migration sea-orm-cli migrate
    2. Generate the entities sea-orm-cli generate entity

    Expected Behavior

    The entity:

    pub struct Model {
        pub id: i32,
        #[sea_orm(column_type = "JsonBinary")]
        pub status: Json,
        #[sea_orm(column_type = "JsonBinary")]
        pub payload: Json,
    }
    

    Actual Behavior

    The entity:

    pub struct Model {
        pub id: i32,
        pub status: Json,
        pub payload: Json,
    }
    

    Reproduces How Often

    Always

    Versions

    โ”‚   โ”œโ”€โ”€ sea-orm v0.10.6
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-orm-macros v0.10.6 (proc-macro)
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-query v0.27.2
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ sea-query-derive v0.2.0 (proc-macro)
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-query-binder v0.2.2
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ sea-query v0.27.2 (*)
    โ”‚   โ”‚   โ”œโ”€โ”€ sea-strum v0.23.0
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ sea-strum_macros v0.23.0 (proc-macro)
    โ”œโ”€โ”€ sea-orm v0.10.6 (*)
    

    From my Docker image, Postgres is:

    image: postgres:14.1

    Additional Information

    n/a

    opened by AngelOnFira 0
Releases(0.10.6)
  • 0.10.6(Dec 23, 2022)

    Enhancements

    • Cast enum values when constructing update many query https://github.com/SeaQL/sea-orm/pull/1178

    Bug Fixes

    • Fixes DeriveColumn (by qualifying IdenStatic::as_str) https://github.com/SeaQL/sea-orm/pull/1280
    • Prevent returning connections to pool with a positive transaction depth https://github.com/SeaQL/sea-orm/pull/1283
    • [sea-orm-codegen] Skip implementing Related if the same related entity is being referenced by a conjunct relation https://github.com/SeaQL/sea-orm/pull/1298
    • [sea-orm-cli] CLI depends on codegen of the same version https://github.com/SeaQL/sea-orm/pull/1299/
    Source code(tar.gz)
    Source code(zip)
  • 0.10.5(Dec 2, 2022)

    New Features

    • Add QuerySelect::columns method - select multiple columns https://github.com/SeaQL/sea-orm/pull/1264
    • Transactions Isolation level and Access mode https://github.com/SeaQL/sea-orm/pull/1230

    Bug Fixes

    • DeriveEntityModel derive macro: when parsing field type, always treat field with Option<T> as nullable column https://github.com/SeaQL/sea-orm/pull/1257

    Enhancements

    • [sea-orm-cli] Generate Related implementation for many-to-many relation with extra columns https://github.com/SeaQL/sea-orm/pull/1260
    • Optimize the default implementation of TryGetableFromJson::try_get_from_json() - deserializing into Self directly without the need of a intermediate serde_json::Value https://github.com/SeaQL/sea-orm/pull/1249
    Source code(tar.gz)
    Source code(zip)
  • 0.10.4(Nov 24, 2022)

    Bug Fixes

    • Fix DeriveActiveEnum expand enum variant starts with number https://github.com/SeaQL/sea-orm/pull/1219
    • [sea-orm-cli] Generate entity file for specified tables only https://github.com/SeaQL/sea-orm/pull/1245
    • Support appending DbErr to MockDatabase https://github.com/SeaQL/sea-orm/pull/1241

    Enhancements

    • Filter rows with IS IN enum values expression https://github.com/SeaQL/sea-orm/pull/1183
    • [sea-orm-cli] Generate entity with relation variant order by name of reference table https://github.com/SeaQL/sea-orm/pull/1229
    Source code(tar.gz)
    Source code(zip)
  • 0.10.3(Nov 14, 2022)

    Bug Fixes

    • [sea-orm-cli] Set search path when initializing Postgres connection for CLI generate entity https://github.com/SeaQL/sea-orm/pull/1212
    • [sea-orm-cli] Generate _ prefix to enum variant starts with number https://github.com/SeaQL/sea-orm/pull/1211
    • Fix composite key cursor pagination https://github.com/SeaQL/sea-orm/pull/1216
      • The logic for single-column primary key was correct, but for composite keys the logic was incorrect

    Enhancements

    • Added Insert::exec_without_returning https://github.com/SeaQL/sea-orm/pull/1208

    House Keeping

    • Remove dependency when not needed https://github.com/SeaQL/sea-orm/pull/1207
    Source code(tar.gz)
    Source code(zip)
  • 0.10.2(Nov 6, 2022)

    Enhancements

    • [sea-orm-rocket] added sqlx_logging to Config https://github.com/SeaQL/sea-orm/pull/1192
    • Collecting metrics for query_one/all https://github.com/SeaQL/sea-orm/pull/1165
    • use GAT to elide StreamTrait lifetime https://github.com/SeaQL/sea-orm/pull/1161

    Bug Fixes

    • corrected the error name UpdateGetPrimaryKey https://github.com/SeaQL/sea-orm/pull/1180

    Upgrades

    • Update MSRV to 1.65

    New Contributors

    • @phidiaLam made their first contribution in https://github.com/SeaQL/sea-orm/pull/1160
    • @sousandrei made their first contribution in https://github.com/SeaQL/sea-orm/pull/1168
    • @frederikhors made their first contribution in https://github.com/SeaQL/sea-orm/pull/1174
    • @jayay made their first contribution in https://github.com/SeaQL/sea-orm/pull/1192

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.10.1...0.10.2

    Source code(tar.gz)
    Source code(zip)
  • 0.10.1(Oct 27, 2022)

    Enhancements

    • [sea-orm-cli] Escape module name defined with Rust keywords https://github.com/SeaQL/sea-orm/pull/1052
    • [sea-orm-cli] Check to make sure migration name doesn't contain hyphen - in it https://github.com/SeaQL/sea-orm/pull/879, https://github.com/SeaQL/sea-orm/pull/1155
    • Support time crate for SQLite https://github.com/SeaQL/sea-orm/pull/995

    Bug Fixes

    • [sea-orm-cli] Generate Related for m-to-n relation https://github.com/SeaQL/sea-orm/pull/1075
    • [sea-orm-cli] Generate model entity with Postgres Enum field https://github.com/SeaQL/sea-orm/pull/1153
    • [sea-orm-cli] Migrate up command apply all pending migrations https://github.com/SeaQL/sea-orm/pull/1010
    • [sea-orm-cli] Conflicting short flag -u when executing migrate generate command https://github.com/SeaQL/sea-orm/pull/1157
    • Prefix the usage of types with sea_orm:: inside DeriveActiveEnum derive macros https://github.com/SeaQL/sea-orm/pull/1146, https://github.com/SeaQL/sea-orm/pull/1154
    • [sea-orm-cli] Generate model with Vec<f32> or Vec<f64> should not derive Eq on the model struct https://github.com/SeaQL/sea-orm/pull/1158

    House Keeping

    • [sea-orm-cli] [sea-orm-migration] Add cli feature to optionally include dependencies that are required by the CLI https://github.com/SeaQL/sea-orm/pull/978

    Upgrades

    • Upgrade sea-schema to 0.10.2 https://github.com/SeaQL/sea-orm/pull/1153

    New Contributors

    • @andy128k made their first contribution in https://github.com/SeaQL/sea-orm/pull/1052
    • @Rheydskey made their first contribution in https://github.com/SeaQL/sea-orm/pull/978

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.10.0...0.10.1

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Oct 23, 2022)

    New Features

    • Better error types (carrying SQLx Error) https://github.com/SeaQL/sea-orm/pull/1002
    • Support array datatype in PostgreSQL https://github.com/SeaQL/sea-orm/pull/1132
    • [sea-orm-cli] Generate entity files as a library or module https://github.com/SeaQL/sea-orm/pull/953
    • [sea-orm-cli] Generate a new migration template with name prefix of unix timestamp https://github.com/SeaQL/sea-orm/pull/947
    • [sea-orm-cli] Generate migration in modules https://github.com/SeaQL/sea-orm/pull/933
    • [sea-orm-cli] Generate DeriveRelation on empty Relation enum https://github.com/SeaQL/sea-orm/pull/1019
    • [sea-orm-cli] Generate entity derive Eq if possible https://github.com/SeaQL/sea-orm/pull/988
    • [sea-orm-cli] Run migration on any PostgreSQL schema https://github.com/SeaQL/sea-orm/pull/1056

    Enhancements

    • Support distinct & distinct_on expression https://github.com/SeaQL/sea-orm/pull/902
    • fn column() also handle enum type https://github.com/SeaQL/sea-orm/pull/973
    • Added acquire_timeout on ConnectOptions https://github.com/SeaQL/sea-orm/pull/897
    • [sea-orm-cli] migrate fresh command will drop all PostgreSQL types https://github.com/SeaQL/sea-orm/pull/864, https://github.com/SeaQL/sea-orm/pull/991
    • Better compile error for entity without primary key https://github.com/SeaQL/sea-orm/pull/1020
    • Added blanket implementations of IntoActiveValue for Option values https://github.com/SeaQL/sea-orm/pull/833
    • Added into_model & into_json to Cursor https://github.com/SeaQL/sea-orm/pull/1112
    • Added set_schema_search_path method to ConnectOptions for setting schema search path of PostgreSQL connection https://github.com/SeaQL/sea-orm/pull/1056
    • Serialize time types as serde_json::Value https://github.com/SeaQL/sea-orm/pull/1042
    • Implements fmt::Display for ActiveEnum https://github.com/SeaQL/sea-orm/pull/986
    • Implements TryFrom<ActiveModel> for Model https://github.com/SeaQL/sea-orm/pull/990

    Bug fixes

    • Trim spaces when paginating raw SQL https://github.com/SeaQL/sea-orm/pull/1094

    Breaking changes

    • Replaced usize with u64 in PaginatorTrait https://github.com/SeaQL/sea-orm/pull/789
    • Type signature of DbErr changed as a result of https://github.com/SeaQL/sea-orm/pull/1002
    • ColumnType::Enum structure changed:
    enum ColumnType {
        // then
        Enum(String, Vec<String>)
    
        // now
        Enum {
            /// Name of enum
            name: DynIden,
            /// Variants of enum
            variants: Vec<DynIden>,
        }
        ...
    }
    
    • A new method array_type was added to ValueType:
    impl sea_orm::sea_query::ValueType for MyType {
        fn array_type() -> sea_orm::sea_query::ArrayType {
            sea_orm::sea_query::ArrayType::TypeName
        }
        ...
    }
    
    • ActiveEnum::name() changed return type to DynIden:
    #[derive(Debug, Iden)]
    #[iden = "category"]
    pub struct CategoryEnum;
    
    impl ActiveEnum for Category {
        // then
        fn name() -> String {
            "category".to_owned()
        }
    
        // now
        fn name() -> DynIden {
            SeaRc::new(CategoryEnum)
        }
        ...
    }
    

    House keeping

    • Documentation grammar fixes https://github.com/SeaQL/sea-orm/pull/1050
    • Replace dotenv with dotenvy in examples https://github.com/SeaQL/sea-orm/pull/1085
    • Exclude test_cfg module from SeaORM https://github.com/SeaQL/sea-orm/pull/1077

    Integration

    • Support rocket_okapi https://github.com/SeaQL/sea-orm/pull/1071

    Upgrades

    • Upgrade sea-query to 0.26 https://github.com/SeaQL/sea-orm/pull/985

    New Contributors

    • @mohs8421 made their first contribution in https://github.com/SeaQL/sea-orm/pull/750
    • @STBoyden made their first contribution in https://github.com/SeaQL/sea-orm/pull/1015
    • @wyatt-herkamp made their first contribution in https://github.com/SeaQL/sea-orm/pull/1012
    • @FistedByDionysus made their first contribution in https://github.com/SeaQL/sea-orm/pull/1013
    • @michidk made their first contribution in https://github.com/SeaQL/sea-orm/pull/1014
    • @zoedberg made their first contribution in https://github.com/SeaQL/sea-orm/pull/1027
    • @jimmycuadra made their first contribution in https://github.com/SeaQL/sea-orm/pull/1041
    • @remlse made their first contribution in https://github.com/SeaQL/sea-orm/pull/933
    • @shpun817 made their first contribution in https://github.com/SeaQL/sea-orm/pull/890
    • @banool made their first contribution in https://github.com/SeaQL/sea-orm/pull/1060
    • @Animeshz made their first contribution in https://github.com/SeaQL/sea-orm/pull/947
    • @w93163red made their first contribution in https://github.com/SeaQL/sea-orm/pull/988
    • @tusharxoxoxo made their first contribution in https://github.com/SeaQL/sea-orm/pull/1050
    • @p0rtL6 made their first contribution in https://github.com/SeaQL/sea-orm/pull/1095
    • @Sylk made their first contribution in https://github.com/SeaQL/sea-orm/pull/1100
    • @wdcocq made their first contribution in https://github.com/SeaQL/sea-orm/pull/833
    • @eum602 made their first contribution in https://github.com/SeaQL/sea-orm/pull/1071
    • @tsirysndr made their first contribution in https://github.com/SeaQL/sea-orm/pull/1127
    • @EstebanBorai made their first contribution in https://github.com/SeaQL/sea-orm/pull/1136
    • @onichandame made their first contribution in https://github.com/SeaQL/sea-orm/pull/1135

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.9.0...0.10.0

    Source code(tar.gz)
    Source code(zip)
  • 0.9.3(Sep 30, 2022)

    Enhancements

    • fn column() also handle enum type https://github.com/SeaQL/sea-orm/pull/973
    • Generate migration in modules https://github.com/SeaQL/sea-orm/pull/933
    • Generate DeriveRelation on empty Relation enum https://github.com/SeaQL/sea-orm/pull/1019
    • Documentation grammar fixes https://github.com/SeaQL/sea-orm/pull/1050

    Bug fixes

    • Implement IntoActiveValue for time types https://github.com/SeaQL/sea-orm/pull/1041
    • Fixed module import for FromJsonQueryResult derive macro https://github.com/SeaQL/sea-orm/pull/1081
    Source code(tar.gz)
    Source code(zip)
  • 0.9.2(Aug 20, 2022)

    Enhancements

    • [sea-orm-cli] Migrator CLI handles init and generate commands https://github.com/SeaQL/sea-orm/pull/931
    • [sea-orm-cli] added with-copy-enums flag to conditional derive Copy on ActiveEnum https://github.com/SeaQL/sea-orm/pull/936

    House keeping

    • Exclude chrono default features https://github.com/SeaQL/sea-orm/pull/950
    • Set minimal rustc version to 1.60 https://github.com/SeaQL/sea-orm/pull/938
    • Update sea-query to 0.26.3

    Notes

    In this minor release, we removed time v0.1 from the dependency graph

    Source code(tar.gz)
    Source code(zip)
  • 0.9.1(Jul 21, 2022)

    Enhancements

    • [sea-orm-cli] Codegen support for VarBinary column type https://github.com/SeaQL/sea-orm/pull/746
    • [sea-orm-cli] Generate entity for SYSTEM VERSIONED tables on MariaDB https://github.com/SeaQL/sea-orm/pull/876

    Bug Fixes

    • RelationDef & RelationBuilder should be Send & Sync https://github.com/SeaQL/sea-orm/pull/898

    House keeping

    • Remove unnecessary async_trait https://github.com/SeaQL/sea-orm/pull/737
    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Jul 17, 2022)

    New Features

    • Cursor pagination (#822)
    • Custom join on conditions (#793)
    • DeriveMigrationName and sea_orm_migration::util::get_file_stem (#736)
    • FromJsonQueryResult for deserializing Json from query result (#794)

    Enhancements

    • Added sqlx_logging_level to ConnectOptions (#800)
    • Added num_items_and_pages to Paginator (#768)
    • Added TryFromU64 for time (#849)
    • Added Insert::on_conflict (#791)
    • Added QuerySelect::join_as and QuerySelect::join_as_rev (#852)
    • Include column name in TryGetError::Null (#853)
    • [sea-orm-cli] Improve logging (#735)
    • [sea-orm-cli] Generate enum with numeric like variants (#588)
    • [sea-orm-cli] Allow old pending migration to be applied (#755)
    • [sea-orm-cli] Skip generating entity for ignored tables (#837)
    • [sea-orm-cli] Generate code for time crate (#724)
    • [sea-orm-cli] Add various blob column types (#850)
    • [sea-orm-cli] Generate entity files with Postgres's schema name (#422)

    Upgrades

    • Upgrade clap to 3.2 (#706)
    • Upgrade time to 0.3 (#834)
    • Upgrade sqlx to 0.6 (#834)
    • Upgrade uuid to 1.0 (#834)
    • Upgrade sea-query to 0.26 (#834)
    • Upgrade sea-schema to 0.9 (#834)

    House keeping

    • Refactor stream metrics (#778)

    Bug Fixes

    • [sea-orm-cli] skip checking connection string for credentials (#851)

    Breaking changes

    • SelectTwoMany::one() has been dropped https://github.com/SeaQL/sea-orm/pull/813, you can get (Entity, Vec<RelatedEntity>) by first querying a single model from Entity, then use [ModelTrait::find_related] on the model.
    • Feature flag revamp

      We now adopt the weak dependency syntax in Cargo. That means the flags ["sqlx-json", "sqlx-chrono", "sqlx-decimal", "sqlx-uuid", "sqlx-time"] are not needed and now removed. Instead, with-time will enable sqlx?/time only if sqlx is already enabled. As a consequence, now the features with-json, with-chrono, with-rust_decimal, with-uuid, with-time will not be enabled as a side-effects of enabling sqlx.

    New Contributors

    • @itsparser made their first contribution in https://github.com/SeaQL/sea-orm/pull/714
    • @Eugeny made their first contribution in https://github.com/SeaQL/sea-orm/pull/716
    • @SH11235 made their first contribution in https://github.com/SeaQL/sea-orm/pull/717
    • @Technik97 made their first contribution in https://github.com/SeaQL/sea-orm/pull/718
    • @frankhorv made their first contribution in https://github.com/SeaQL/sea-orm/pull/719
    • @hilary888 made their first contribution in https://github.com/SeaQL/sea-orm/pull/741
    • @aslamplr made their first contribution in https://github.com/SeaQL/sea-orm/pull/776
    • @Tricked-dev made their first contribution in https://github.com/SeaQL/sea-orm/pull/712
    • @kyoto7250 made their first contribution in https://github.com/SeaQL/sea-orm/pull/735
    • @cache-missing made their first contribution in https://github.com/SeaQL/sea-orm/pull/792
    • @POPPIN-FUMI made their first contribution in https://github.com/SeaQL/sea-orm/pull/803
    • @xiaoquisme made their first contribution in https://github.com/SeaQL/sea-orm/pull/818
    • @SandaruKasa made their first contribution in https://github.com/SeaQL/sea-orm/pull/800
    • @liberwang1013 made their first contribution in https://github.com/SeaQL/sea-orm/pull/791
    • @smonv made their first contribution in https://github.com/SeaQL/sea-orm/pull/706
    • @fistons made their first contribution in https://github.com/SeaQL/sea-orm/pull/768
    • @dragonnn made their first contribution in https://github.com/SeaQL/sea-orm/pull/769
    • @lingdu1234 made their first contribution in https://github.com/SeaQL/sea-orm/pull/857
    • @nahuakang made their first contribution in https://github.com/SeaQL/sea-orm/pull/724
    • @a5huynh made their first contribution in https://github.com/SeaQL/sea-orm/pull/856

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.8.0...0.9.0

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(May 9, 2022)

    New Features

    • [sea-orm-cli] sea migrate generate to generate a new, empty migration file https://github.com/SeaQL/sea-orm/pull/656

    Enhancements

    • Add max_connections option to CLI https://github.com/SeaQL/sea-orm/pull/670
    • Derive Eq, Clone for DbErr https://github.com/SeaQL/sea-orm/pull/677
    • Add is_changed to ActiveModelTrait https://github.com/SeaQL/sea-orm/pull/683

    Bug Fixes

    • Fix DerivePrimaryKey with custom primary key column name https://github.com/SeaQL/sea-orm/pull/694
    • Fix DeriveEntityModel macros override column name https://github.com/SeaQL/sea-orm/pull/695
    • Fix Insert with no value supplied using DEFAULT https://github.com/SeaQL/sea-orm/pull/589

    Breaking changes

    • Migration utilities are moved from sea-schema to sea-orm repo, under a new sub-crate sea-orm-migration. sea_schema::migration::prelude should be replaced by sea_orm_migration::prelude in all migration files

    Upgrades

    • Upgrade sea-query to 0.24.x, sea-schema to 0.8.x
    • Upgrade example to Actix Web 4, Actix Web 3 remains https://github.com/SeaQL/sea-orm/pull/638
    • Added Tonic gRPC example https://github.com/SeaQL/sea-orm/pull/659
    • Upgrade GraphQL example to use axum 0.5.x
    • Upgrade axum example to 0.5.x

    Fixed Issues

    • Failed to insert row with only default values https://github.com/SeaQL/sea-orm/issues/420
    • Reduce database connections to 1 during codegen https://github.com/SeaQL/sea-orm/issues/511
    • Column names with single letters separated by underscores are concatenated https://github.com/SeaQL/sea-orm/issues/630
    • Update Actix Web examples https://github.com/SeaQL/sea-orm/issues/639
    • Lower function missing https://github.com/SeaQL/sea-orm/issues/672
    • is_changed on active_model https://github.com/SeaQL/sea-orm/issues/674
    • Failing find_with_related with column_name attribute https://github.com/SeaQL/sea-orm/issues/693

    New Contributors

    • @niuhuan made their first contribution in https://github.com/SeaQL/sea-orm/pull/636
    • @Chaostheorie made their first contribution in https://github.com/SeaQL/sea-orm/pull/638
    • @giripriyadarshan made their first contribution in https://github.com/SeaQL/sea-orm/pull/659
    • @fairingrey made their first contribution in https://github.com/SeaQL/sea-orm/pull/667
    • @mibes404 made their first contribution in https://github.com/SeaQL/sea-orm/pull/673
    • @benluelo made their first contribution in https://github.com/SeaQL/sea-orm/pull/670
    • @SebastienGllmt made their first contribution in https://github.com/SeaQL/sea-orm/pull/677
    • @viktorbahr made their first contribution in https://github.com/SeaQL/sea-orm/pull/656
    • @kirawi made their first contribution in https://github.com/SeaQL/sea-orm/pull/683

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.7.1...0.8.0

    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Mar 26, 2022)

    New Features

    • Update ActiveModel by JSON by @billy1624 in https://github.com/SeaQL/sea-orm/pull/492
    • Supports time crate by @billy1624 https://github.com/SeaQL/sea-orm/pull/602
    • Allow for creation of indexes for PostgreSQL and SQLite @nickb937 https://github.com/SeaQL/sea-orm/pull/593
    • Added delete_by_id @ShouvikGhosh2048 https://github.com/SeaQL/sea-orm/pull/590
    • Implement PaginatorTrait for SelectorRaw @shinbunbun https://github.com/SeaQL/sea-orm/pull/617

    Enhancements

    • Added axum graphql example by @aaronleopold in https://github.com/SeaQL/sea-orm/pull/587
    • Add example for integrate with jsonrpsee by @hunjixin https://github.com/SeaQL/sea-orm/pull/632
    • Codegen add serde derives to enums, if specified by @BenJeau https://github.com/SeaQL/sea-orm/pull/463
    • Codegen Unsigned Integer by @billy1624 https://github.com/SeaQL/sea-orm/pull/397
    • Add Send bound to QueryStream and TransactionStream by @sebpuetz https://github.com/SeaQL/sea-orm/pull/471
    • Add Send to StreamTrait by @nappa85 https://github.com/SeaQL/sea-orm/pull/622
    • sea as an alternative bin name to sea-orm-cli by @ZhangHanDong https://github.com/SeaQL/sea-orm/pull/558

    Bug Fixes

    • Fix codegen with Enum in expanded format by @billy1624 https://github.com/SeaQL/sea-orm/pull/624
    • Fixing and testing into_json of various field types by @billy1624 https://github.com/SeaQL/sea-orm/pull/539

    Breaking changes

    • Exclude mock from default features by @billy1624 https://github.com/SeaQL/sea-orm/pull/562
    • create_table_from_entity will no longer create index for MySQL, please use the new method create_index_from_entity

    Documentations

    • Describe default value of ActiveValue on document by @Ken-Miura in https://github.com/SeaQL/sea-orm/pull/556
    • community: add axum-book-management by @lz1998 in https://github.com/SeaQL/sea-orm/pull/564
    • Add Backpack to project showcase by @JSH32 in https://github.com/SeaQL/sea-orm/pull/567
    • Add mediarepo to showcase by @Trivernis in https://github.com/SeaQL/sea-orm/pull/569
    • COMMUNITY: add a link to Svix to showcase by @tasn in https://github.com/SeaQL/sea-orm/pull/537
    • Update COMMUNITY.md by @naryand in https://github.com/SeaQL/sea-orm/pull/570
    • Update COMMUNITY.md by @BobAnkh in https://github.com/SeaQL/sea-orm/pull/568
    • Update COMMUNITY.md by @KaniyaSimeji in https://github.com/SeaQL/sea-orm/pull/566
    • Update COMMUNITY.md by @aaronleopold in https://github.com/SeaQL/sea-orm/pull/565
    • Update COMMUNITY.md by @gudaoxuri in https://github.com/SeaQL/sea-orm/pull/572
    • Update Wikijump's entry in COMMUNITY.md by @ammongit in https://github.com/SeaQL/sea-orm/pull/573
    • Update COMMUNITY.md by @koopa1338 in https://github.com/SeaQL/sea-orm/pull/574
    • Update COMMUNITY.md by @gengteng in https://github.com/SeaQL/sea-orm/pull/580
    • Update COMMUNITY.md by @Yama-Tomo in https://github.com/SeaQL/sea-orm/pull/582
    • add oura-postgres-sink to COMMUNITY.md by @rvcas in https://github.com/SeaQL/sea-orm/pull/594
    • Add rust-example-caster-api to COMMUNITY.md by @bkonkle in https://github.com/SeaQL/sea-orm/pull/623

    Fixed Issues

    • orm-cli generated incorrect type for #[sea_orm(primary_key)]. Should be u64. Was i64. https://github.com/SeaQL/sea-orm/issues/295
    • how to update dynamicly from json value https://github.com/SeaQL/sea-orm/issues/346
    • Make DatabaseConnection Clone with the default features enabled https://github.com/SeaQL/sea-orm/issues/438
    • Updating mutiple fields in a Model by passing a reference https://github.com/SeaQL/sea-orm/issues/460
    • SeaORM CLI not adding serde derives to Enums https://github.com/SeaQL/sea-orm/issues/461
    • sea-orm-cli generates wrong datatype for nullable blob https://github.com/SeaQL/sea-orm/issues/490
    • Support the time crate in addition (instead of?) chrono https://github.com/SeaQL/sea-orm/issues/499
    • PaginatorTrait for SelectorRaw https://github.com/SeaQL/sea-orm/issues/500
    • sea_orm::DatabaseConnection should implement Clone by default https://github.com/SeaQL/sea-orm/issues/517
    • How do you seed data in migrations using ActiveModels? https://github.com/SeaQL/sea-orm/issues/522
    • Datetime fields are not serialized by .into_json() on queries https://github.com/SeaQL/sea-orm/issues/530
    • Update / Delete by id https://github.com/SeaQL/sea-orm/issues/552
    • #[sea_orm(indexed)] only works for MySQL https://github.com/SeaQL/sea-orm/issues/554
    • sea-orm-cli generate --with-serde does not work on Postegresql custom type https://github.com/SeaQL/sea-orm/issues/581
    • sea-orm-cli generate --expanded-format panic when postgres table contains enum type https://github.com/SeaQL/sea-orm/issues/614
    • UUID fields are not serialized by .into_json() on queries https://github.com/SeaQL/sea-orm/issues/619

    New Contributors

    • @aaronleopold made their first contribution in https://github.com/SeaQL/sea-orm/pull/565
    • @BenJeau made their first contribution in https://github.com/SeaQL/sea-orm/pull/463
    • @sebpuetz made their first contribution in https://github.com/SeaQL/sea-orm/pull/471
    • @nickb937 made their first contribution in https://github.com/SeaQL/sea-orm/pull/593
    • @shinbunbun made their first contribution in https://github.com/SeaQL/sea-orm/pull/617
    • @ShouvikGhosh2048 made their first contribution in https://github.com/SeaQL/sea-orm/pull/590
    • @hunjixin made their first contribution in https://github.com/SeaQL/sea-orm/pull/632
    • @ZhangHanDong made their first contribution in https://github.com/SeaQL/sea-orm/pull/558

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.6.0...0.7.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Feb 6, 2022)

    New Features

    • Migration Support by @billy1624 in https://github.com/SeaQL/sea-orm/pull/335
    • Support DateTime<Utc> & DateTime<Local> by @billy1624 in https://github.com/SeaQL/sea-orm/pull/489
    • Add max_lifetime connection option by @billy1624 in https://github.com/SeaQL/sea-orm/pull/493

    Enhancements

    • Model with Generics by @billy1624 in https://github.com/SeaQL/sea-orm/pull/400
    • Add Poem example by @sunli829 in https://github.com/SeaQL/sea-orm/pull/446
    • Codegen column_name proc_macro attribute by @billy1624 in https://github.com/SeaQL/sea-orm/pull/433
    • Easy joins with MockDatabase #447 by @cemoktra in https://github.com/SeaQL/sea-orm/pull/455

    Bug Fixes

    • CLI allow generate entity with url without password by @billy1624 in https://github.com/SeaQL/sea-orm/pull/436
    • Support up to 6-ary composite primary key by @billy1624 in https://github.com/SeaQL/sea-orm/pull/423
    • Fix FromQueryResult when Result is redefined by @tasn in https://github.com/SeaQL/sea-orm/pull/495
    • Remove r# prefix when deriving FromQueryResult by @smrtrfszm in https://github.com/SeaQL/sea-orm/pull/494

    Breaking Changes

    • Name conflict of foreign key constraints when two entities have more than one foreign keys by @billy1624 in https://github.com/SeaQL/sea-orm/pull/417

    Fixed Issues

    • Is it possible to have 4 values Composite Key? https://github.com/SeaQL/sea-orm/issues/352
    • Support DateTime<Utc> & DateTime<Local> https://github.com/SeaQL/sea-orm/issues/381
    • Codegen column_name proc_macro attribute if column name isn't in snake case https://github.com/SeaQL/sea-orm/issues/395
    • Model with Generics https://github.com/SeaQL/sea-orm/issues/402
    • Foreign key constraint collision when multiple keys exist between the same two tables https://github.com/SeaQL/sea-orm/issues/405
    • sea-orm-cli passwordless database user causes "No password was found in the database url" error https://github.com/SeaQL/sea-orm/issues/435
    • Testing joins with MockDatabase https://github.com/SeaQL/sea-orm/issues/447
    • Surface max_lifetime connection option https://github.com/SeaQL/sea-orm/issues/475

    New Contributors

    • @sunli829 made their first contribution in https://github.com/SeaQL/sea-orm/pull/446
    • @tasn made their first contribution in https://github.com/SeaQL/sea-orm/pull/495
    • @smrtrfszm made their first contribution in https://github.com/SeaQL/sea-orm/pull/494
    • @cemoktra made their first contribution in https://github.com/SeaQL/sea-orm/pull/455

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.5.0...0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Feb 6, 2022)

    Fixed Issues

    • Why insert, update, etc return a ActiveModel instead of Model? https://github.com/SeaQL/sea-orm/issues/289
    • Rework ActiveValue https://github.com/SeaQL/sea-orm/issues/321
    • Some missing ActiveEnum utilities https://github.com/SeaQL/sea-orm/issues/338

    Merged PRs

    • First metric and tracing implementation by @nappa85 in https://github.com/SeaQL/sea-orm/pull/373
    • Update sea-orm to depends on SeaQL/sea-query#202 by @billy1624 in https://github.com/SeaQL/sea-orm/pull/370
    • Codegen ActiveEnum & Create Enum From ActiveEnum by @billy1624 in https://github.com/SeaQL/sea-orm/pull/348
    • Axum example: update to Axum v0.4.2 by @ttys3 in https://github.com/SeaQL/sea-orm/pull/383
    • Fix rocket version by @Gabriel-Paulucci in https://github.com/SeaQL/sea-orm/pull/384
    • Insert & Update Return Model by @billy1624 in https://github.com/SeaQL/sea-orm/pull/339
    • Rework ActiveValue by @billy1624 in https://github.com/SeaQL/sea-orm/pull/340
    • Add wrapper method ModelTrait::delete by @billy1624 in https://github.com/SeaQL/sea-orm/pull/396
    • Add docker create script for contributors to setup databases locally by @billy1624 in https://github.com/SeaQL/sea-orm/pull/378
    • Log with tracing-subscriber by @billy1624 in https://github.com/SeaQL/sea-orm/pull/399
    • Codegen SQLite by @billy1624 in https://github.com/SeaQL/sea-orm/pull/386
    • PR without clippy warmings in file changed tab by @billy1624 in https://github.com/SeaQL/sea-orm/pull/401
    • Rename sea-strum lib back to strum by @billy1624 in https://github.com/SeaQL/sea-orm/pull/361

    Breaking Changes

    • ActiveModel::insert and ActiveModel::update return Model instead of ActiveModel
    • Method ActiveModelBehavior::after_save takes Model as input instead of ActiveModel
    • Rename method sea_orm::unchanged_active_value_not_intended_for_public_use to sea_orm::Unchanged
    • Rename method ActiveValue::unset to ActiveValue::not_set
    • Rename method ActiveValue::is_unset to ActiveValue::is_not_set
    • PartialEq of ActiveValue will also check the equality of state instead of just checking the equality of value

    New Contributors

    • @ttys3 made their first contribution in https://github.com/SeaQL/sea-orm/pull/383
    • @Gabriel-Paulucci made their first contribution in https://github.com/SeaQL/sea-orm/pull/384

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.2...0.5.0

    Source code(tar.gz)
    Source code(zip)
  • 0.4.2(Dec 12, 2021)

    Fixed Issues

    • Delete::many() doesn't work when schema_name is defined https://github.com/SeaQL/sea-orm/issues/362
    • find_with_related panic https://github.com/SeaQL/sea-orm/issues/374
    • How to define rust type of TIMESTAMP? https://github.com/SeaQL/sea-orm/issues/344
    • Add Table on the generated Column enum https://github.com/SeaQL/sea-orm/issues/356

    Merged PRs

    • Delete::many() with TableRef by @billy1624 in https://github.com/SeaQL/sea-orm/pull/363
    • Fix related & linked with enum columns by @billy1624 in https://github.com/SeaQL/sea-orm/pull/376
    • Temporary Fix: Handling MySQL & SQLite timestamp columns by @billy1624 in https://github.com/SeaQL/sea-orm/pull/379
    • Add feature to generate table Iden by @Sytten in https://github.com/SeaQL/sea-orm/pull/360

    New Contributors

    • @Sytten made their first contribution in https://github.com/SeaQL/sea-orm/pull/360

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.1...0.4.2

    Source code(tar.gz)
    Source code(zip)
  • 0.4.1(Dec 4, 2021)

    Fixed Issues

    • Is it possible to have 4 values Composite Key? https://github.com/SeaQL/sea-orm/issues/352
    • [sea-orm-cli] Better handling of relation generations https://github.com/SeaQL/sea-orm/issues/239

    Merged PRs

    • Add TryFromU64 trait for DateTime<FixedOffset>. by @kev0960 in https://github.com/SeaQL/sea-orm/pull/331
    • add offset and limit by @lz1998 in https://github.com/SeaQL/sea-orm/pull/351
    • For some reason the axum_example fail to compile by @billy1624 in https://github.com/SeaQL/sea-orm/pull/355
    • Support Up to 6 Values Composite Primary Key by @billy1624 in https://github.com/SeaQL/sea-orm/pull/353
    • Codegen Handle Self Referencing & Multiple Relations to the Same Related Entity by @billy1624 in https://github.com/SeaQL/sea-orm/pull/347

    New Contributors

    • @kev0960 made their first contribution in https://github.com/SeaQL/sea-orm/pull/331
    • @lz1998 made their first contribution in https://github.com/SeaQL/sea-orm/pull/351

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.4.0...0.4.1

    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Nov 19, 2021)

    Fixed Issues

    • Disable SQLx query logging https://github.com/SeaQL/sea-orm/issues/290
    • Code generated by sea-orm-cli cannot pass clippy https://github.com/SeaQL/sea-orm/issues/296
    • Should return detailed error message for connection failure https://github.com/SeaQL/sea-orm/issues/310
    • DateTimeWithTimeZone does not implement Serialize and Deserialize https://github.com/SeaQL/sea-orm/issues/319
    • Support returning clause to avoid database hits https://github.com/SeaQL/sea-orm/issues/183

    Merged PRs

    • chore: update to Rust 2021 Edition by @sno2 in https://github.com/SeaQL/sea-orm/pull/273
    • Enumeration - 3 by @billy1624 in https://github.com/SeaQL/sea-orm/pull/274
    • Enumeration - 2 by @billy1624 in https://github.com/SeaQL/sea-orm/pull/261
    • Codegen fix clippy warnings by @billy1624 in https://github.com/SeaQL/sea-orm/pull/303
    • Add axum example by @YoshieraHuang in https://github.com/SeaQL/sea-orm/pull/297
    • Enumeration by @billy1624 in https://github.com/SeaQL/sea-orm/pull/258
    • Add PaginatorTrait and CountTrait for more constrains by @YoshieraHuang in https://github.com/SeaQL/sea-orm/pull/306
    • Continue PaginatorTrait by @billy1624 in https://github.com/SeaQL/sea-orm/pull/307
    • Refactor Schema by @billy1624 in https://github.com/SeaQL/sea-orm/pull/309
    • Detailed connection errors by @billy1624 in https://github.com/SeaQL/sea-orm/pull/312
    • Suppress ouroboros missing docs warnings by @billy1624 in https://github.com/SeaQL/sea-orm/pull/288
    • with-json feature requires chrono/serde by @billy1624 in https://github.com/SeaQL/sea-orm/pull/320
    • Pass the argument entity.table_ref() instead of just entity. by @josh-codes in https://github.com/SeaQL/sea-orm/pull/318
    • Unknown types could be a newtypes instead of ActiveEnum by @billy1624 in https://github.com/SeaQL/sea-orm/pull/324
    • Returning by @billy1624 in https://github.com/SeaQL/sea-orm/pull/292

    Breaking Changes

    • Refactor paginate() & count() utilities into PaginatorTrait. You can use the paginator as usual but you might need to import PaginatorTrait manually when upgrading from previous version.
      use futures::TryStreamExt;
      use sea_orm::{entity::*, query::*, tests_cfg::cake};
      
      let mut cake_stream = cake::Entity::find()
          .order_by_asc(cake::Column::Id)
          .paginate(db, 50)
          .into_stream();
      
      while let Some(cakes) = cake_stream.try_next().await? {
          // Do something on cakes: Vec<cake::Model>
      }
      
    • The helper struct Schema converting EntityTrait into different sea-query statement now has to be initialized with DbBackend.
      use sea_orm::{tests_cfg::*, DbBackend, Schema};
      use sea_orm::sea_query::TableCreateStatement;
      
      // 0.3.x
      let _: TableCreateStatement = Schema::create_table_from_entity(cake::Entity);
      
      // 0.4.x
      let schema: Schema = Schema::new(DbBackend::MySql);
      let _: TableCreateStatement = schema.create_table_from_entity(cake::Entity);
      
    • When performing insert or update operation on ActiveModel against PostgreSQL, RETURNING clause will be used to perform select in a single SQL statement.
      // For PostgreSQL
      cake::ActiveModel {
          name: Set("Apple Pie".to_owned()),
          ..Default::default()
      }
      .insert(&postgres_db)
      .await?;
      
      assert_eq!(
          postgres_db.into_transaction_log(),
          vec![Transaction::from_sql_and_values(
              DbBackend::Postgres,
              r#"INSERT INTO "cake" ("name") VALUES ($1) RETURNING "id", "name""#,
              vec!["Apple Pie".into()]
          )]);
      
      // For MySQL & SQLite
      cake::ActiveModel {
          name: Set("Apple Pie".to_owned()),
          ..Default::default()
      }
      .insert(&other_db)
      .await?;
      
      assert_eq!(
          other_db.into_transaction_log(),
          vec![
              Transaction::from_sql_and_values(
                  DbBackend::MySql,
                  r#"INSERT INTO `cake` (`name`) VALUES (?)"#,
                  vec!["Apple Pie".into()]
              ),
              Transaction::from_sql_and_values(
                  DbBackend::MySql,
                  r#"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` = ? LIMIT ?"#,
                  vec![15.into(), 1u64.into()]
              )]);
      

    New Contributors

    • @sno2 made their first contribution in https://github.com/SeaQL/sea-orm/pull/273
    • @YoshieraHuang made their first contribution in https://github.com/SeaQL/sea-orm/pull/297
    • @josh-codes made their first contribution in https://github.com/SeaQL/sea-orm/pull/318

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.2...0.4.0

    Source code(tar.gz)
    Source code(zip)
  • 0.3.2(Nov 2, 2021)

    Fixed Issues

    • Support for BYTEA Postgres primary keys https://github.com/SeaQL/sea-orm/issues/286

    Merged PRs

    • Documentation for sea-orm by @charleschege in https://github.com/SeaQL/sea-orm/pull/280
    • Support Vec<u8> primary key by @billy1624 in https://github.com/SeaQL/sea-orm/pull/287

    New Contributors

    • @charleschege made their first contribution in https://github.com/SeaQL/sea-orm/pull/280

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.1...0.3.2

    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Oct 23, 2021)

    Fixed Issues

    • Align case trasforms across derive macros #262
    • Added is_null and is_not_null to ColumnTrait #267

    Merged PRs

    • Changed manual url parsing to use Url crate by @AngelOnFira in https://github.com/SeaQL/sea-orm/pull/253
    • Test self referencing relation by @billy1624 in https://github.com/SeaQL/sea-orm/pull/256
    • Unify case-transform using the same crate by @billy1624 in https://github.com/SeaQL/sea-orm/pull/264
    • CI cleaning by @AngelOnFira in https://github.com/SeaQL/sea-orm/pull/263
    • CI install sea-orm-cli in debug mode by @billy1624 in https://github.com/SeaQL/sea-orm/pull/265

    New Contributors

    • @AngelOnFira made their first contribution in https://github.com/SeaQL/sea-orm/pull/253

    Full Changelog: https://github.com/SeaQL/sea-orm/compare/0.3.0...0.3.1

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Oct 15, 2021)

    https://www.sea-ql.org/SeaORM/blog/2021-10-15-whats-new-in-0.3.0

    • Built-in Rocket support
    • ConnectOptions
    let mut opt = ConnectOptions::new("protocol://username:[email protected]/database".to_owned());
    opt.max_connections(100)
        .min_connections(5)
        .connect_timeout(Duration::from_secs(8))
        .idle_timeout(Duration::from_secs(8));
    let db = Database::connect(opt).await?;
    
    • [#211] Throw error if none of the db rows are affected
    assert_eq!(
        Update::one(cake::ActiveModel {
            name: Set("Cheese Cake".to_owned()),
            ..model.into_active_model()
        })
        .exec(&db)
        .await,
        Err(DbErr::RecordNotFound(
            "None of the database rows are affected".to_owned()
        ))
    );
    
    assert_eq!(
        Update::many(cake::Entity)
            .col_expr(cake::Column::Name, Expr::value("Cheese Cake".to_owned()))
            .filter(cake::Column::Id.eq(2))
            .exec(&db)
            .await,
        Ok(UpdateResult { rows_affected: 0 })
    );
    
    • [#223] ActiveValue::take() & ActiveValue::into_value() without unwrap()
    • [#205] Drop Default trait bound of PrimaryKeyTrait::ValueType
    • [#222] Transaction & streaming
    • [#210] Update ActiveModelBehavior API
    • [#240] Add derive DeriveIntoActiveModel and IntoActiveValue trait
    • [#237] Introduce optional serde support for model code generation
    • [#246] Add #[automatically_derived] to all derived implementations
    Source code(tar.gz)
    Source code(zip)
  • 0.2.6(Oct 9, 2021)

  • 0.2.5(Oct 6, 2021)

  • 0.2.4(Oct 1, 2021)

    https://www.sea-ql.org/SeaORM/blog/2021-10-01-whats-new-in-0.2.4

    • [[#186]] [sea-orm-cli] Foreign key handling
    • [[#191]] [sea-orm-cli] Unique key handling
    • [[#182]] find_linked join with alias
    • [[#202]] Accept both postgres:// and postgresql://
    • [[#208]] Support feteching T, (T, U), (T, U, P) etc
    • [[#209]] Rename column name & column enum variant
    • [[#207]] Support chrono::NaiveDate & chrono::NaiveTime
    • Support Condition::not (from sea-query)
    Source code(tar.gz)
    Source code(zip)
  • 0.2.3(Sep 22, 2021)

  • 0.2.2(Sep 17, 2021)

    • [[#105]] Compact entity format
    • [[#132]] Add ActiveModel insert & update
    • [[#129]] Add set method to UpdateMany
    • [[#118]] Initial lock support
    • [[#167]] Add FromQueryResult::find_by_statement
    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Sep 4, 2021)

  • 0.2.0(Sep 3, 2021)

    • [[#37]] Rocket example
    • [[#114]] log crate and env-logger
    • [[#103]] InsertResult to return the primary key's type
    • [[#89]] Represent several relations between same types by Linked
    • [[#59]] Transforming an Entity into TableCreateStatement
    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Sep 3, 2021)

  • 0.1.2(Aug 22, 2021)

    • [[#68]] Added DateTimeWithTimeZone as supported attribute type
    • [[#70]] Generate arbitrary named entity
    • [[#80]] Custom column name
    • [[#81]] Support join on multiple columns
    • [[#99]] Implement FromStr for ColumnTrait
    Source code(tar.gz)
    Source code(zip)
Owner
SeaQL
Building data intensive applications in Rust
SeaQL
A safe, extensible ORM and Query Builder for Rust

A safe, extensible ORM and Query Builder for Rust API Documentation: latest release โ€“ master branch Homepage Diesel gets rid of the boilerplate for da

Diesel 9.7k Jan 3, 2023
an orm for rust

rustorm Rustorm Rustorm is an SQL-centered ORM with focus on ease of use on conversion of database types to their appropriate rust type. Selecting rec

Jovansonlee Cesar 236 Dec 19, 2022
Diesel - A safe, extensible ORM and Query Builder for Rust

A safe, extensible ORM and Query Builder for Rust API Documentation: latest release โ€“ master branch Homepage Diesel gets rid of the boilerplate for da

Takayuki Maeda 0 Aug 31, 2020
Ormlite - An ORM in Rust for developers that love SQL.

ormlite ormlite is an ORM in Rust for developers that love SQL. It provides the following, while staying close to SQL, both in syntax and performance:

Kurt Wolf 28 Jan 1, 2023
Diesel - ORM and Query Builder for Rust

A safe, extensible ORM and Query Builder for Rust API Documentation: latest release โ€“ master branch Homepage Diesel gets rid of the boilerplate for da

Diesel 9.7k Jan 6, 2023
Rust High Performance compile-time ORM(RBSON based)

WebSite | ็ฎ€ไฝ“ไธญๆ–‡ | Showcase | ๆกˆไพ‹ A highly Performant,Safe,Dynamic SQL(Compile time) ORM framework written in Rust, inspired by Mybatis and MybatisPlus.

rbatis 1.7k Jan 7, 2023
ORM for ScyllaDb and Cassandra

ScyllaDb/Cassandra Object-Relation Mapper Features This library contains several crates with the following features: Automatic map tables to Rust stru

null 36 Jan 1, 2023
CRUD system of book-management with ORM and JWT for educational purposes.

Book management English | ไธญๆ–‡ Required Rust MySQL 5.7 Usage Execute init.sql to create tables. Set environment variable DATABASE_URL and JWT_SECRET in

null 32 Dec 28, 2022
Bind the Prisma ORM query engine to any programming language you like โค๏ธ

Prisma Query Engine C API Bind the Prisma ORM query engine to any programming language you like โค๏ธ Features Rust bindings for the C API Static link li

Prisma ORM for community 10 Dec 15, 2022
Bind the Prisma ORM query engine to any programming language you like โค๏ธ

Prisma Query Engine C API Bind the Prisma ORM query engine to any programming language you like โค๏ธ Features Rust bindings for the C API Static link li

Odroe 6 Sep 9, 2022
Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules - port of vfsstat.c

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules The vfs and vtab This is a port of the official ext/misc/vfsstat.c sqlite3 e

Manos Pitsidianakis 28 Oct 10, 2022
๐Ÿงฐ The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.

SQLx ?? The Rust SQL Toolkit Install | Usage | Docs Built with โค๏ธ by The LaunchBadge team SQLx is an async, pure Rustโ€  SQL crate featuring compile-tim

launchbadge 7.6k Dec 31, 2022
TDS 7.2+ (mssql / Microsoft SQL Server) async driver for rust

Tiberius A native Microsoft SQL Server (TDS) client for Rust. Supported SQL Server versions Version Support level Notes 2019 Tested on CI 2017 Tested

Prisma 189 Dec 25, 2022
Simple, async embedded Rust

Cntrlr - Simple, asynchronous embedded Cntrlr is an all-in-one embedded platform for writing simple asynchronous applications on top of common hobbyis

Branan Riley 11 Jun 3, 2021
Rust async runtime based on io-uring.

Monoio A thread-per-core Rust runtime with io_uring. ไธญๆ–‡่ฏดๆ˜Ž Design Goal As a runtime based on io_uring, Monoio is designed to be the most efficient and

Bytedance Inc. 2.4k Jan 6, 2023
Quick Pool: High Performance Rust Async Resource Pool

Quick Pool High Performance Rust Async Resource Pool Usage DBCP Database Backend Adapter Version PostgreSQL tokio-postgres qp-postgres Example use asy

Seungjae Park 13 Aug 23, 2022
Dataloader-rs - Rust implementation of Facebook's DataLoader using async-await.

Dataloader Rust implementation of Facebook's DataLoader using async-await. Documentation Features Batching load requests with caching Batching load re

cksac 229 Nov 27, 2022
High-level async Cassandra client written in 100% Rust.

CDRS tokio CDRS is production-ready Apache Cassandra driver written in pure Rust. Focuses on providing high level of configurability to suit most use

Kamil Rojewski 73 Dec 26, 2022
Automatically deleted async I/O temporary files in Rust

async-tempfile Provides the TempFile struct, an asynchronous wrapper based on tokio::fs for temporary files that will be automatically deleted when th

Markus Mayer 3 Jan 4, 2023