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

Support for Vec<impl From<Value>> in models #151

Closed
tqwewe opened this issue Sep 12, 2021 · 6 comments
Closed

Support for Vec<impl From<Value>> in models #151

tqwewe opened this issue Sep 12, 2021 · 6 comments

Comments

@tqwewe
Copy link
Contributor

tqwewe commented Sep 12, 2021

Models should allow for columns which are arrays.

For example a Postgres array column called "images":

"images" VARCHAR[] NOT NULL DEFAULT ARRAY[]::VARCHAR[],

Should integrate with a type Vec<String> on a model.

pub struct Model {
    pub id: Uuid,
    pub images: Vec<String>,
}

Currently, it throws an error:

the trait From<Vec<std::string::String>> is not implemented for sea_orm::Value

@billy1624
Copy link
Member

But all other databases (MySQL & SQLite) does not support array

@tqwewe
Copy link
Contributor Author

tqwewe commented Sep 14, 2021

Oh I see, I wonder if this feature could only be enabled when you have the postgres feature flag active.

I did see that MySQL has a JSON type and a JSON_ARRAY function... I wonder if it could also be implemented for MySQL and it works on JSON types, but if the JSON is an object, it will fail?

@BastienVigneron
Copy link

BastienVigneron commented Sep 28, 2021

+1

I just test sea-orm-cli generate entity from my model (which work fine with Diesel.rs), and I obtain the following code for entities :

...
    #[sea_orm(column_type = "Custom(\"array\".to_owned())", nullable)]
    pub other_patient_ids: Option<String>,
...

for a column declared as other_patient_ids text[], in PostgreSQL.

Clearly, other_patient_ids should be a Option<Vec<String>>.
Is it planned to support ?

@tyt2y3
Copy link
Member

tyt2y3 commented Mar 15, 2022

Cont'd in #576

@tyt2y3 tyt2y3 closed this as completed Mar 15, 2022
@emmiegit
Copy link
Contributor

I'm confused, why was this closed? The other issue #576 is less detailed and is more recent. Is it because this is being worked on?

@tyt2y3
Copy link
Member

tyt2y3 commented Mar 16, 2022

just to consolidate the discussions

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

5 participants