Skip to content

Replace SeaORM's ColumnType - #1395

Merged
tyt2y3 merged 5 commits into
masterfrom
replace-columntype
Jan 29, 2023
Merged

tyt2y3 merged 5 commits into
masterfrom
replace-columntype

Conversation

@billy1624

@billy1624 billy1624 commented Jan 14, 2023 •

Copy link
Copy Markdown
Member

PR Info

Breaking Changes

  • sea_orm::ColumnType was replaced by sea_query::ColumnType
  • ColumnType::Custom takes sea_query::DynIden instead of String and thus a new method custom is added
// Compact Entity
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "fruit")]
pub struct Model {
-   #[sea_orm(column_type = r#"Custom("citext".to_owned())"#)]
+   #[sea_orm(column_type = r#"custom("citext")"#)]
    pub column: String,
}
// Expanded Entity
impl ColumnTrait for Column {
    type EntityName = Entity;

    fn def(&self) -> ColumnDef {
        match self {
-           Self::Column => ColumnType::Custom("citext".to_owned()).def(),
+           Self::Column => ColumnType::custom("citext").def(),
        }
    }
}
  • ColumnType::Binary became a tuple variant which take sea_query::BlobSize
  • Methods ColumnType::def was being moved into ColumnTypeTrait

@tyt2y3

tyt2y3 commented Jan 15, 2023

Copy link
Copy Markdown
Member

Looks good so far. It's nice to remove duplicate code.

let col_defs = vec![
"ColumnType::String(Some(255u32)).def()",
"ColumnType::Custom(\"cus_col\".to_owned()).def()",
"ColumnType::custom(\"cus_col\").def()",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm... this lower casing is odd. But nice to omit the to_owned indeed

@tyt2y3 tyt2y3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good after fixing clippy

@billy1624
billy1624 marked this pull request as ready for review January 19, 2023 13:38
@tyt2y3
tyt2y3 merged commit 08a5e87 into master Jan 29, 2023
@tyt2y3
tyt2y3 deleted the replace-columntype branch January 29, 2023 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Replace SeaORM's ColumnType and IdenStatic with its SeaQuery's counterparts

2 participants