beedb icon indicating copy to clipboard operation
beedb copied to clipboard

Can not enter null values

Open hobbs opened this issue 12 years ago • 2 comments

It's possible I'm missing something, but how do you enter null values in for columns?

For example, giving the code:

type Userinfo struct {
    Uid     int `PK` 
    Age    int
    Departname  string
    Created     time.Time
}

var saveone Userinfo
saveone.Username = "Test Add User"
saveone.Departname = "Dept"
saveone.Created = time.Now()
orm.Save(&saveone)

How would I enter a NULL value for Age? This code will insert a "0" for Age.

hobbs avatar Feb 05 '13 05:02 hobbs

@hobbs, in go a null value depends on the type. For an int the null value is 0, for string it is "", etc...

danawoodman avatar Dec 24 '13 03:12 danawoodman

That's more of an FYI statement than an answer to how to add a NULL field in the DB, sorry.

danawoodman avatar Dec 24 '13 03:12 danawoodman