-
Theres a lack of documentation (this may be specific to the mySQL driver) about having to use model.Name.String = "Whatever" before calling Insert. I haven't looked deeper into this, but is it because the table allows nulls, or because the default value is set to null? Or did i compleatly miss something somewhere? :) Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@TekknoGuy this is sort of a well understood pattern in Go because the sql standard library has these same types of types in them: https://pkg.go.dev/database/sql#NullBool - the null package we use simply makes them a bit more ergonomic model.Name = null.FromString("Whatever") // this creates a non-null null.String Whether or not that excuses a lack of documentation I'm not sure :D It's because your table column allows null that the null types are used. If you do |
Beta Was this translation helpful? Give feedback.
@TekknoGuy this is sort of a well understood pattern in Go because the sql standard library has these same types of types in them: https://pkg.go.dev/database/sql#NullBool - the null package we use simply makes them a bit more ergonomic
Whether or not that excuses a lack of documentation I'm not sure :D
It's because your table column allows null that the null types are used. If you do
NOT NULL
you will just see astring
.