-
Notifications
You must be signed in to change notification settings - Fork 551
Open
Labels
Description
When trying to update a column of array type (in our case a StringArray one), the Update fails if a nil is provided instead of an empty slice.
This is really hard to identify beforehand because the array type is usually an alias to a slice of a base type (i.e StringArray
aliases as []string
) and therefore it's fairly easy to make an assignment without any type casting.
In short, the generated SQL code looks something like this against a column specified to be NOT NULL
:
UPDATE table SET string_array_column = NULL WHERE ...;
I'm opening the issue to discuss how would be the best way to approach this. One possible solution that comes to my mind is to make an analogy of the database/sql
types by creating Null*Array
variants.
WDYT?
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
Select code repository
Activity
aarondl commentedon Sep 12, 2019
@glerchundi definitely I think we should remain consistent in our
Null*
approach instead of trying to come up with a new solution specifically for arrays.In my opinion this is working perfectly, if you put
nil
in, you get an error because your intent is incorrect. The error messages may be terrible, it may be surprising, and it may be a tough thing to remember to do (meaning the ergonomics around the current behavior are awful), but it's doing the right thing I think which is not compromising your data.If we do create a Null* for the array types, I'm not opposed to generating a nicer error message for the ArrayType when it's nil, given that it should no longer be used when nil isn't possible.