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
ENUMs treat empty strings "" as if they were <nil> on CSV import, resulting in error #5807
Comments
We debated this one for a while today, and @jennifersp even coded up a nice PR for this. It's a good issue, but I'm not comfortable yet with some of the effects of the change. Since there is a workaround currently (using enum integer values instead of the string values, like you mentioned), I think we shouldn't rush into a change that might affect other uses of Here's my reasoning:
I'm happy to leave this one open if we want to see if other customers hit this issue, but for right now, I think we should not make this change. I'm open to other ideas or compromises of course. My favorite idea that Jennifer I discussed was having a command line flag that switches this behavior. That felt like the cleanest solution to me, but I was hesitant to add that until we had some more customer feedback on needing this. |
It's a bug only in the sense the the behavior of value,"","" is not the same across the board. In any non-ENUM field, the value "" is considered the empty string, and distinct from NULL. The counterintuitive behavior is treating "" like NULL only in the context of ENUMs.
the NULL value would be just But in the spirit of what you say: yes, it's not widespread, and I also agree that now that we've figured out another solution for our use case, it's not high priority. |
I was thinking about this some more and I tested how our Ultimately, if we're already making this distinction in the import/export code, then I'm totally fine with continuing it for enums. It cleanly handles my earlier concern about needing to treat all Apologies that I didn't catch that we were already making that distinction in the import/export code! Given that we are, you've convinced me that this is a bug and we should give enum values the same handling to differentiate between |
Empty strings "" are distinct from
null
, but when an ENUM has an empty string "" as a possible value, providing that empty string results in it being interpreted asnull
.a.sql
data.csv
Do:
Result:
This is a problem when the "" empty string is part of a primary key with a blank value.
Right now the workaround is to use the index of the ENUM. Starting with this file,
data_workaround.csv
do:
Then you'll get correctly:
The text was updated successfully, but these errors were encountered: