How do I INSERT / UPDATE false value into a field with boolean type?
When I'm setting corresponding ORM-structure field to 'fase', result query translate it to NULL.
Example:
``type TSDBMProxy struct {
tableName struct{}
Id int64
Available bool}
psdbmProxy.Available = true
sResult, err = Db.Model(psdbmProxy).
Column("available").
Update()
``
results in query:
UPDATE proxy AS tsdbm_proxy SET "available" = NULL WHERE tsdbm_proxy."id" = 3
How do I overcome the issue?
Add sql:",notnull" tag to the struct field.
This is such a confusing behaviour.
I had the same problem, but my column declaration was:
active boolean default true not null,
And inserting a struct with Active: false would produce a SQL insert with active = TRUE.
Now setting the sql:",notnull" tag fixes the problem, but it's not clear why it was required in the first place.
Most helpful comment
This is such a confusing behaviour.
I had the same problem, but my column declaration was:
And inserting a struct with
Active: falsewould produce a SQL insert withactive = TRUE.Now setting the
sql:",notnull"tag fixes the problem, but it's not clear why it was required in the first place.