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

Fix Sqlite BLOB type. #44

Merged
merged 1 commit into from
Feb 20, 2022
Merged

Fix Sqlite BLOB type. #44

merged 1 commit into from
Feb 20, 2022

Conversation

Hirtol
Copy link
Contributor

@Hirtol Hirtol commented Feb 11, 2022

Closes SeaQL/sea-orm#490

Not entirely sure why it was done with an alias, but by changing the ColumnType to binary the following schema (when used with sea-orm-cli):

CREATE TABLE "Books"
(
    id             INTEGER                                  NOT NULL PRIMARY KEY AUTOINCREMENT,
    title          TEXT                                     NOT NULL,
    hash           BLOB                                     NOT NULL UNIQUE,
)

Used to produce:

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "Books")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub title: String,
    #[sea_orm(column_type = "Custom(\"BLOB\".to_owned())")]
    pub hash: String,
}

And will now produce:

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "Books")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub title: String,
    pub hash: Vec<u8>,
}

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Thanks!! @Hirtol

@billy1624 billy1624 requested a review from tyt2y3 February 13, 2022 15:21
@tyt2y3 tyt2y3 merged commit db674ed into SeaQL:master Feb 20, 2022
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.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sea-orm-cli generates wrong datatype for nullable blob
3 participants