db
db copied to clipboard
Insert and Save Queries incompatible with postgres default values (v3)
An insert or save query (that goes to an insert) will pass through all columns, and using a null value if that column had no input.
This causes failures with postgres in the form of either;
- the column that has a default is set to nil
- the column that has a default yields an error because it has a not null clause that should be protected by a default
will test with upper v4 soon
Hello @kipply,
Is this case something that could be solved by using the omitempty option? That word tells upper to ignore the field when it has a zero value:
type User struct {
ID int `db:"id,omitempty"`
}
Let me know if your case is different.