-
Notifications
You must be signed in to change notification settings - Fork 6
Description
When inserting or updating JSONB columns errors are being thrown, this seems to be due to JSON/JSONB sharing the same parameter code generator. There is no issue on reading side, only the writing side.
Error when updating a JSONB column:
Npgsql.PostgresException: 42804: column "data" is of type jsonb but expression is of type text
Changing the generated code from ( since it's a nullable column ):
command.Parameters.AddWithValue("@data", args.Data.HasValue ? args.Data.Value.GetRawText() : (object)DBNull.Value);
to
command.Parameters.AddWithValue("@data", args.Data.HasValue ? args.Data.Value : (object)DBNull.Value);
fixes the issue.
I've looked at potential code fixes. The easiest is a simple special clause in GetWriterFn for jsonb columns, but it isn't the prettiest.
Versions:
- sqlc-gen-csharp: v0.21.0
- sqlc: v1.29.0