Adding a new (non-nullable) JSON column populates it with an empty string (invalid JSON) #32353
Labels
area-json
area-migrations
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
When adding a new column, we add it with a column DEFAULT for the CLR default of the type (see this code in MigrationsModelDiffer); this means that the JSON column default is an empty string:
For PostgreSQL, this fails since the column is typed as
jsonb
, and an empty string isn't a valid JSON document. I've worked around this in the migrations SQL generator (PR), but that's not the right place for this - it notably leaves the empty string in the scaffolded migration code.This doesn't error on e.g. SQL Server because the column type is
nvarchar(max)
, but we end up with invalid data in the column. I'm not sure if this can cause a real bug, but it certainly could.Note relationship with #28596.
/cc @maumar
The text was updated successfully, but these errors were encountered: