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

Mysql f64 problem #44

Closed
samsamai opened this issue Jul 13, 2021 · 2 comments
Closed

Mysql f64 problem #44

samsamai opened this issue Jul 13, 2021 · 2 comments

Comments

@samsamai
Copy link
Contributor

samsamai commented Jul 13, 2021

I switched over to the mysql adaptor for one of the tests and I started getting the following error:

thread 'main' panicked at 'range end index 8 out of range for slice of length 4', /Users/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.4.3/src/lib.rs:2199:28

I tracked it down to the profit_margin in the bakery model which was using f64. Changing it to f32 fixed the panic.

Here is an extract of tests/common/bakery_chain/bakery.rs on the origin/ss/mysql_try branch:

impl EntityName for Entity {
    fn table_name(&self) -> &str {
        "bakery"
    }
}

#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
pub struct Model {
    pub id: i32,
    pub name: String,
    pub profit_margin: f64,
}
@tyt2y3
Copy link
Member

tyt2y3 commented Jul 13, 2021

I guess because it is defined as float in schema instead of double

.col(ColumnDef::new(bakery::Column::ProfitMargin).float())

It worked in SQLite case because I think SQLite only has 64 bit floats.

@samsamai
Copy link
Contributor Author

I see, thanks for that!

SebastienGllmt pushed a commit to dcSpark/sea-orm that referenced this issue Apr 13, 2022
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

No branches or pull requests

2 participants