use generics to reduce field boilerplate
There's a significant duplication of the field code:
type OauthToken_Scope_Field struct {
_set bool
_null bool
_value string
}
func OauthToken_Scope(v string) OauthToken_Scope_Field {
return OauthToken_Scope_Field{_set: true, _value: v}
}
func (f OauthToken_Scope_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (OauthToken_Scope_Field) _Column() string { return "scope" }
Could be replaced by:
type OauthToken_Scope_Field struct { NullableField[string] }
func OauthToken_Scope(v string) OauthToken_Scope_Field {
return OauthToken_Scope_Field{NullableField: FieldOf(v)}
}
func (OauthToken_Scope_Field) _Column() string { return "scope" }
It's not clear how big the benefit is here. Also, maybe there's a better approach for this.
one of the things about the Field types is that the zero value is invalid (that's why there's both a _set and a _null), and you have to use the constructors to create values correctly. using embedding like this would negate that somewhat. it's also not very many lines of code saved.
Hmm, maybe there's a way to make something shorter? But, I was not able to come up with something shorter.
Maybe structs and delegating the field checks to lint time could work. i.e. get rid of the field types altogether.