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

NewNullString from empty string #171

Closed
gennaios opened this issue Apr 13, 2019 · 1 comment
Closed

NewNullString from empty string #171

gennaios opened this issue Apr 13, 2019 · 1 comment

Comments

@gennaios
Copy link

Hello,

I'm wondering about how NewNullString handles strings of value "". If the example is as such:

title := "" // set from elsewhere

sugg := &Suggestion{
	Title:		NewNullString(title),
	CreatedAt:	time.Now(),
}

It seems that the database column value of title is set to "" rather than NULL.

@gennaios
Copy link
Author

Figured it out by testing for length of string and then inserting NewNullString. This seems to be the idiomatic way.

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

1 participant