volatiletech / null

reasonable handling of nullable values

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StringFrom empty string

Linus-Boehm opened this issue · comments

shouldn't the default behaviour of StringFrom called with an empty string result in Valid == false

So the code would look something like this:

func StringFrom(s string) String {
        valid := len(s) > 0
	return NewString(s, valid)
}

No hard opinion here and we will probably not change this, as this would be a breaking change especially for sqlboiler, just wondering what the reason behind this decision is. Currently this leads to nullable strings on the DB are set per default to
an empty string instead of null, when passing values from an API model with omitempty