sqlboiler
sqlboiler copied to clipboard
NullDecimal, when nil, results in zero being inserted instead of NULL
Hey! I'm converting some values from decimals to nullable decimals so we can distinguish between zero and unset. I've noticed some odd behaviour in the way records are inserted.
The schema has these fields defined as types.NullDecimal and the data going in is the zero-value of this type, with a nil pointer to Big inside. However, after insertion, the actual row contains 0 not NULL which is wrong.
I dumped out the object being written to the DB and right after that 580 there are three nil values, these are the fields I've defined as possibly NULL in the schema, and SQLBoiler has inferred+generated types.NullDecimal for my models:
{00000000-0000-0000-0000-000000000001 0001-01-01 00:00:00 +0000 UTC 00000000-0000-0000-0000-000000000001 20 580 nil nil nil true [] <nil> {}}
However, after insertion:

There are no update queries, this is just some isolated code.
Having the same problem 😞