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

feat: postgres arrays #233

Merged
merged 19 commits into from
Jan 17, 2022
Merged

Conversation

chesedo
Copy link
Contributor

@chesedo chesedo commented Oct 28, 2021

Allows generating and importing postgres arrays to close #171. Also covers array of json generation and json importing to close #67.

Things that don't work

  • Generating array of Uuids: uuids end up as Value::String which cause them to be text here. Adding a Value::Uuid type should fix this, I will just need guidance about how please 😄
  • Generating empty arrays don't work since they cannot be identified here. But generating an array with min length of 1 as a one_of null does work.
  • Generating the postgres array of json type (json[]) does not work. Instead just using the simple postgres json type with an array in it ({[]}) does work - schema and generation definition

@chesedo chesedo force-pushed the encode_postgres_arrays branch from 8fd7bee to dcb9511 Compare October 29, 2021 07:00
@christos-h
Copy link
Member

LGTM in general. One question, why did you change the return type of:

fn try_match_value(row: &PgRow, column: &PgColumn) -> Result<serde_json::Value> 

from Value to serde_json::Value?

@chesedo
Copy link
Contributor Author

chesedo commented Nov 5, 2021

@christoshadjiaslanis for json import support. The json object can be read by sqlx here inside try_match_value. I had no way to convert the serde_json::Value to Value and it seemed wasteful since it would be turned back to serde_json::Value eventually. So just went with serde_json::Value all the way.

Copy link
Contributor

@bmoxb bmoxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor thing but otherwise looks good to me too :)

synth/src/datasource/postgres_datasource.rs Outdated Show resolved Hide resolved
@chesedo chesedo force-pushed the encode_postgres_arrays branch 2 times, most recently from 4bdbc90 to 1800fea Compare January 3, 2022 10:21
@chesedo
Copy link
Contributor Author

chesedo commented Jan 4, 2022

Suggestion addressed, thanks @WiredSound 🥳

Copy link
Contributor

@bmoxb bmoxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me :)

@chesedo chesedo force-pushed the encode_postgres_arrays branch from d276b14 to 5482054 Compare January 17, 2022 10:49
@brokad brokad merged commit 286770f into shuttle-hq:master Jan 17, 2022
@chesedo chesedo deleted the encode_postgres_arrays branch February 9, 2022 12:17
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

Successfully merging this pull request may close these issues.

Allow import/export of arbitrary postgres array types Support postgres json and jsonb types
4 participants