gorm
gorm copied to clipboard
Specify a nonzero value if no value is specified
Describe the feature
Hi, I've been using Gorm for a long time.
I use uncle bob's clean architecture. My logic is that at the beginning of the project I paint all storage areas in the same style.
Sometimes it happens that I need to set a field to a non-zero value and I resort to non-standard solutions that take up a lot of my time.
I had an idea, why not use sql.Null*
as this
type NullString struct {
String string
Valid bool // Valid is true if String is not NULL
}
If you specify valid as true, but do not specify a value, then the query will look like this:
SELECT * FROM "processes" WHERE "processes"."logic" = ''
I suggest turning it into:
SELECT * FROM "processes" WHERE "processes"."logic" NOT NULL
Motivation
I don't know what to write here