Skip to content

Fix: Dropping multiple types in Postgres - #623

Merged
ikrivosheev merged 4 commits into
SeaQL:0.28.xfrom
PreetamSing:0.28.x
Apr 7, 2023
Merged

ikrivosheev merged 4 commits into
SeaQL:0.28.xfrom
PreetamSing:0.28.x

Conversation

@PreetamSing

Copy link
Copy Markdown
Contributor

Bug Fixes

  • Following code in Rust omits the comma in SQL statement, which causes error from Postgres (as of sea-query version 0.28.3). This issue has been fixed.
use sea_query::{extension::postgres::Type, *};

#[derive(Iden)]
enum KycStatus {
   #[iden = "kyc_status"]
   Type,
   Pending,
   Approved,
}

#[derive(Iden)]
enum FontFamily {
   #[iden = "font_family"]
   Type,
   Aerial,
   Forte,
}

assert_eq!(
    Type::drop()
        .if_exists()
        .names([
            SeaRc::new(KycStatus::Type) as DynIden,
            SeaRc::new(FontFamily::Type) as DynIden,
        ])
        .cascade()
        .to_string(PostgresQueryBuilder),
    r#"DROP TYPE IF EXISTS "kyc_status""font_family" CASCADE"#
);

Changes

  • Add comma if multiple names are passed to TypeDropStatement.
  • Doc-test/example for dropping multiple types in single TypeDropStatement.

Other considerations

  • I'm fairly new to this code and have, sort of, reverse engineered this bug to fix it. Hence, I'm not fully aware of how my code can affect other things, though all the tests passed.
  • Please update the dependency in sea-orm crate, if you merge this.

@ikrivosheev ikrivosheev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@PreetamSing hello! Thank for the PR. A small suggestion)

Comment thread src/backend/postgres/types.rs Resolved

@ikrivosheev ikrivosheev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@PreetamSing thank you! LGTM!

@ikrivosheev

Copy link
Copy Markdown
Contributor

@billy1624 @tyt2y3 can we make a small patch release with the fix?

@billy1624 billy1624 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.

@billy1624

Copy link
Copy Markdown
Member

@billy1624 @tyt2y3 can we make a small patch release with the fix?

I agree, we should backport this to 0.28.x

@PreetamSing
PreetamSing requested a review from billy1624 March 21, 2023 15:07
@ikrivosheev

ikrivosheev commented Mar 27, 2023 •

Copy link
Copy Markdown
Contributor

@billy1624, can you review the PR?

@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.

Thank you for the contribution.

@tyt2y3

tyt2y3 commented Apr 3, 2023

Copy link
Copy Markdown
Member

I agree, we should backport this to 0.28.x

Agreed.

@ikrivosheev
ikrivosheev merged commit 7366588 into SeaQL:0.28.x Apr 7, 2023
@ikrivosheev

Copy link
Copy Markdown
Contributor

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.

4 participants