Skip to content

(VDB-1230) Add type whitelist to PersistModels#72

Merged
gslaughl merged 1 commit intostagingfrom
vdb-1230-type-whitelist
Apr 6, 2020
Merged

(VDB-1230) Add type whitelist to PersistModels#72
gslaughl merged 1 commit intostagingfrom
vdb-1230-type-whitelist

Conversation

@gslaughl
Copy link
Copy Markdown

@gslaughl gslaughl commented Apr 1, 2020

Small change allowing PersistModels to accept values of the type *pq.StringArray, to make it easier to deal with inserting values into Postgres array columns.


func isValidValue(value interface{}) bool {
switch value.(type) {
case *pq.StringArray:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not really sure why driver.IsValue doesn't consider this a valid type. But pq.StringArray definitely works with the tx.Exec function; in fact I'm pretty sure that's the type's main use-case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if driver.IsValue doesn't return true because a driver doesn't necessarily have to implement a string array? 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sounds legit! Tbh I'm not totally sure what the driver is; I kind of assumed it was responsible for converting Go values into something that Postgres can understand. But I guess I must be misunderstanding/missing something 😅


func isValidValue(value interface{}) bool {
switch value.(type) {
case *pq.StringArray:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if driver.IsValue doesn't return true because a driver doesn't necessarily have to implement a string array? 🤔

@gslaughl gslaughl merged commit 09da08a into staging Apr 6, 2020
@gslaughl gslaughl deleted the vdb-1230-type-whitelist branch April 6, 2020 21:41
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.

2 participants