Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not enter null values #21

Open
hobbs opened this issue Feb 5, 2013 · 2 comments
Open

Can not enter null values #21

hobbs opened this issue Feb 5, 2013 · 2 comments

Comments

@hobbs
Copy link

hobbs commented Feb 5, 2013

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.

@danawoodman
Copy link

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

@danawoodman
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants