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

How to use multiple schema's with enum types #1576

Closed
rex-remind101 opened this issue Dec 7, 2021 · 4 comments
Closed

How to use multiple schema's with enum types #1576

rex-remind101 opened this issue Dec 7, 2021 · 4 comments

Comments

@rex-remind101
Copy link

When I use an enum similar to the following:

create type a.state as enum (
  'on',
  'off');

with this corresponding representation in Rust:

#[derive(PartialEq, Debug, sqlx::Type)]
#[sqlx(type_name = "a.state", rename_all = "snake_case")]
pub enum State {
    On,
    Off,
}

during deserialization from a query I will receive the following error:

operator does not exist: a.state = text

however, barring no naming conflicts with any other schema if we drop the schema name a from type_name deserialization will work correctly. E.g.:

#[derive(PartialEq, Debug, sqlx::Type)]
#[sqlx(type_name = "state", rename_all = "snake_case")]
pub enum State {
    On,
    Off,
}

The issue is, we use multiple different schemas which means we may have other enums where we share the same type names from different schemas even though the types are completely different. This will create an ambiguity where we must qualify by schema so in general we want to always try and qualify by schema.

Is it possible to qualify by schema here? If not, is there some alternative way to get this to work with multiple schemas?

@rex-remind101
Copy link
Author

bump

@rex-remind101
Copy link
Author

bump bump

@abonander
Copy link
Collaborator

Instead of bumping this issue, we'd appreciate it if you took a second to check if it's already been reported, and it looks like something similar already was: #1171

And of course, we'd welcome anyone to take a shot at fixing it.

@abonander
Copy link
Collaborator

Closed by #3252

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