SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
7.3k stars 513 forks source link

`#[sea_orm(indexed)]` only works for MySQL #554

Closed grtlr closed 2 years ago

grtlr commented 2 years ago

Description

Using the #[sea_orm(indexed)] property only works for the MySQL backend and crashes when using sqlite.

Steps to Reproduce

Put the #[sea_orm(indexed)] property on any field of a struct that derives DeriveEntityModel while using a sqlite backend.

Expected Behavior

Ideally it would create the index, but at least it shouldn't crash, emitting an error at compile time.

Actual Behavior

It crashes.

Reproduces How Often

Everytime 😉.

Versions

I'm running sea-orm v0.6.0.

Additional Information

It might be helpful to emphasize this in the appropriate sections of the documentation.

nickb937 commented 2 years ago

I'd opened a similar issue, incorrectly against sea-query, too : https://github.com/SeaQL/sea-query/issues/232

billy1624 commented 2 years ago

Thanks!! @grtlr

It might be helpful to emphasize this in the appropriate sections of the documentation.

As discussed on Discord the first thing I would do was this.

tyt2y3 commented 2 years ago

We should separate the logic from create_table_from_entity and extract to a new function create_index_from_entity