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 citext #104

Closed
cortopy opened this issue Nov 27, 2022 · 9 comments
Closed

Support citext #104

cortopy opened this issue Nov 27, 2022 · 9 comments

Comments

@cortopy
Copy link

cortopy commented Nov 27, 2022

Motivation

citext is a popular extension and when enabled, seaography thinks it's an enum an generates invalid code

Proposed Solutions

Recognise that citext is pretty much like Text for all purposes that matter for client code. Maybe just an alias?

Additional Information

This is the code generated, which is wrong:

#[derive(
    Debug,
    Clone,
    PartialEq,
    EnumIter,
    DeriveActiveEnum,
    Eq,
    Copy,
    async_graphql::Enum,
    seaography::macros::EnumFilter,
)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "citext")]
pub enum Citext {}

sqlx doesn't support citext easily either as per launchbadge/sqlx#295. However, I don't know if seaorm/seaography could do something about it

@karatakis
Copy link
Collaborator

@billy1624
Copy link
Member

Hey @cortopy, could you illustrate the use case of citext? I'm not super familiar with it. Thanks!!

@karatakis
Copy link
Collaborator

karatakis commented Nov 30, 2022

@billy1624 it is a plugin for PostgreSQL, that provides a new data type citext that the SQL database treats a column as a case insensitive string. More info here https://www.postgresql.org/docs/current/citext.html

@cortopy do not mind to tell me if I am wrong.

@cortopy
Copy link
Author

cortopy commented Nov 30, 2022

@karatakis that's exactly it. The citext type is provided natively by postgres, so all it takes to enable is CREATE EXTENSION citext.

Seaography currently thinks that citext is an enum type, while for all purposes, it's just the same as text.

I've been looking a bit more on seaorm and I think the issue also stems from the limited support there for user types. It seems that only enum user types are supported, but in postgres not all user types are enums. There are also composite, range, extension-enabled, etc.

So anybody using any other type will get an enum generated that is just not right.

@billy1624
Copy link
Member

Can we represent citext as String in Rust?

@cortopy
Copy link
Author

cortopy commented Dec 2, 2022

I'd say so yes

@billy1624
Copy link
Member

Alright, then it's more related to sea-schema. SeaQL/sea-schema#89
I'll keep this issue open until it has been solved

@billy1624
Copy link
Member

I've managed to support citext in SeaORM. Please check SeaQL/sea-orm#1304

@karatakis
Copy link
Collaborator

This issue is not present in #114, wait for 1.0.0 release :)

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

3 participants