Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace SeaORM's ColumnType #1395

Merged
merged 5 commits into from
Jan 29, 2023
Merged

Replace SeaORM's ColumnType #1395

merged 5 commits into from
Jan 29, 2023

Conversation

billy1624
Copy link
Member

@billy1624 billy1624 commented Jan 14, 2023

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
Copy link
Member

tyt2y3 commented Jan 15, 2023

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

@@ -464,7 +462,7 @@ mod tests {
let columns = setup();
let col_defs = vec![
"ColumnType::String(Some(255u32)).def()",
"ColumnType::Custom(\"cus_col\".to_owned()).def()",
"ColumnType::custom(\"cus_col\").def()",
Copy link
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

Copy link
Member

@tyt2y3 tyt2y3 left a comment

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