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

Add support for nullable arrays with infer_schema!. #690

Open
Aaronepower opened this Issue Feb 12, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@Aaronepower

Aaronepower commented Feb 12, 2017

Currently infer_schema! generates the this schema from this psql. Which is incorrect since the elements of the array could be null.

Sql

CREATE TABLE posts (
  id SERIAL PRIMARY KEY,
  title VARCHAR NOT NULL,
  body timestamptz[7] NOT NULL,
  published BOOLEAN NOT NULL DEFAULT 'f'
)

Generated schema

table! {
    posts (id) {
        id -> Int4,
        title -> Varchar,
        body -> Array<Timestamptz>,
        published -> Bool,
    }
}
@sgrif

This comment has been minimized.

Member

sgrif commented Feb 12, 2017

To clarify, I want to continue to have the generated type be Array<Timestamptz>, but make sure that deserializing to Vec<Option<NaiveDateTime>> deserializes successfully. Even though considering it to be Array<Timestamptz> is technically incorrect, as it could in theory have a null in there, I want to provide some flexibility here. There is no way to represent whether the elements of an array can or cannot be null in postgres.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment