Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Basically, this is the continuation of the changes on postgres driver part: go-gorm/postgres#296
and must not be merged before postgres driver changes is merged
Hi @jinzhu and team, please review when you have a moment. Any feedbacks are welcome. Thanks!
What did this pull request do?
Handle postgres array types
User Case Description
Currently, when we we have column with array type in postgres database, we need to use or create custom type in our go program so that our program (with gorm) can map the type from/to database.
For example, we can't do this by default, because gorm will throw something like
unsupported data type: &[]
we need to create custom type, for instance:
Then, use it in the model
By this PR, we can just implement like this, without having to use/create custom type for each array column
to achieve this, we just need to enable it via config
Compatibility and Tests
The logic of array handling is placed specifically on postgres driver so that gorm core remains clean, extensible, and database-agnostic. Since a new gorm core test case depends on new changes on postgres driver (which is new config attribute), we need to make sure that changes on postgres driver must be merged before changes on gorm core. However, it is fine if they are not merged simulatenously since this is backward compatible
Tests
New gorm core using new postgres driverExisting gorm core using new postgres driver