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

Implement PgHasArrayType with derive(sqlx::Type) #2262

Closed
laralove143 opened this issue Dec 30, 2022 · 1 comment
Closed

Implement PgHasArrayType with derive(sqlx::Type) #2262

laralove143 opened this issue Dec 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@laralove143
Copy link

laralove143 commented Dec 30, 2022

Is your feature request related to a problem? Please describe.
Currently if one wants to use a type in an array they have to implement the trait manually:

impl PgHasArrayType for Foo {
    fn array_type_info() -> PgTypeInfo {
        PgTypeInfo::with_name("_foo")
    }
}

This is unpredictable and can get repetitive with many types

Describe the solution you'd like
Deriving sqlx::Type implicitly implements this trait following the _{name} format

Describe alternatives you've considered

  • There could be another derive for this: derive(sqlx::Type, sqlx::TypeArray)
  • There could be an attribute to do this #[derive(sqlx::Type)] then #[sqlx(array)]
  • It could be derived implicitly by default, but that could be disabled or renamed with #[sqlx(array_name = "__foo")] or #[sqlx(array = false)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants