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

Inserting actual none value of Option<Date> results in panic #227

Closed
Dlordos opened this issue Oct 5, 2021 · 1 comment · Fixed by #228
Closed

Inserting actual none value of Option<Date> results in panic #227

Dlordos opened this issue Oct 5, 2021 · 1 comment · Fixed by #228
Assignees

Comments

@Dlordos
Copy link

Dlordos commented Oct 5, 2021

I have already brought it up in the Discord channel, but would like to open an issue for further investigation.

When I try to insert a Option<Date>wit value None the inserting fails with panic.

DB: Postgres
Version. 0.2.4

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "users")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub created_at: DateTimeWithTimeZone
    // the problematic type 
    #[sea_orm(column_type = "Date", nullable)]
    pub birth_date: Option<Date>
}
#[post("/")]
async fn create(
    data: web::Data<AppState>,
) -> Result<HttpResponse, Error> {
    let conn = &data.conn;

    // Simulate incoming data from json that could be none
    let fakeData = FakeData {
        date: Option::None
    };

    Users::ActiveModel {
        id: Set(Uuid::new_v4()),
        birth_date: Set(fakeData.date),
        ..Default::default()
    }.insert(conn)
      .await
      .expect("could not insert user");

    Ok(HttpResponse::new(StatusCode::OK))
}
thread 'actix-rt|system:0|arbiter:0' panicked at 'not Value::Date', /Users/tyrus/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/sea-query-0.16.5/src/value.rs:347:18
@tyt2y3
Copy link
Member

tyt2y3 commented Oct 6, 2021

0.2.5

arpancodes pushed a commit to arpancodes/sea-orm that referenced this issue Apr 8, 2022
Fix UNIQUE table index expression syntax for sqlite
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 a pull request may close this issue.

3 participants