Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

ltree #510

Closed
cemoktra opened this issue Feb 9, 2022 · 13 comments
Closed

ltree #510

cemoktra opened this issue Feb 9, 2022 · 13 comments

Comments

@cemoktra
Copy link
Contributor

cemoktra commented Feb 9, 2022

We just played around with ltrees. sea-orm-cli currently generates an empty enum. Maybe for the special ltree case it shoud generate something like

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ltree")]
pub enum Ltree {
    Value(String)
}

Currently this ends up in error: Missing macro attribute, either string_valueornum_value should be specified, so there would need to be a way to extract the string out of the Value variant.

@billy1624
Copy link
Member

Hey @cemoktra, I guess you need to implement ActiveEnum manually instead of deriving DeriveActiveEnum.
https://www.sea-ql.org/SeaORM/docs/generate-entity/enumeration#manual-implementation

@cemoktra
Copy link
Contributor Author

cemoktra commented Feb 9, 2022

Ok also possible, and what about mapping ltree to TEXT?

@cemoktra
Copy link
Contributor Author

cemoktra commented Feb 9, 2022

But I think I'll provide some changes for ltree

@billy1624
Copy link
Member

I'm not sure how ltree works.

But for ActiveEnum,

  • on insert, it will generate SQL 'enum_value' AS enum_type
  • on select, it will generate SQL enum_column AS text

@cemoktra
Copy link
Contributor Author

I started with the basic work on sqlx: launchbadge/sqlx#1696

@billy1624
Copy link
Member

Thanks!! @cemoktra
Let me know if you need any help on it!

@cemoktra
Copy link
Contributor Author

Yeah maybe. Currently sea-query does not depend on sqlx itself, but in order to use my new type it will

@cemoktra
Copy link
Contributor Author

Do you have any opinion on how to integrate this into seaql?

@billy1624
Copy link
Member

I think we can treat ltree as a simple string? Then, we don't need any additional SQLx dependency.
launchbadge/sqlx#1696 (comment)

@cemoktra
Copy link
Contributor Author

cemoktra commented Feb 11, 2022

Currently i get thread 'test::test' panicked at 'not implemented', sea-orm/src/driver/sqlx_postgres.rs:8:1 when trying to filter for an LTree with .eq, also .contains wants a String instead of PgLTree

.filter(test::Column::Ltree.eq(ltree))

Just doing a query works

@cemoktra
Copy link
Contributor Author

Same for insert

@cemoktra
Copy link
Contributor Author

Ok found the missing piece, sorry

@tyt2y3
Copy link
Member

tyt2y3 commented Mar 31, 2022

This is sad but I think our general response to "support a particular Postgres feature" will be "we will gladly accept PR" for now

@SeaQL SeaQL locked and limited conversation to collaborators Mar 31, 2022
@tyt2y3 tyt2y3 converted this issue into discussion #652 Mar 31, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants