-
Notifications
You must be signed in to change notification settings - Fork 125
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
use with github.com/volatiletech/null/v9 panics #127
Comments
Hi @msonawane. Panicking function But still, we should be able to create debug sql from valuer interface. The fix would probably be, something like this: if valuer, ok := bindVal.(driver.Valuer); ok {
val, err := valuer.Value()
if err != nil {
return err.Error()
}
return argToString(val)
}
panic(fmt.Sprintf("jet: %s type can not be used as SQL query parameter", reflect.TypeOf(value).String())) |
@go-jet thank you Looks like this will impact all other types which are not in type switch (null.Int64) etc. Any suggestions ? another issue I have is to identify errors coming from database to better represent state on front end and logs etc. right now i am having few functions to classify errors like
ideally this should be part of go-jet but thats specific to drivers used. What should be a good way to handle this |
The solution should work for all
I personally don't see any benefit of using null types over raw pointers. I always use raw pointers, but I did saw a couple of projects using null types.
Yeah, that's probably preferred way to handle it. My view: #109 (comment) |
@go-jet thanks for your inputs. will it be possible to generate all constraints on table so users will have a type safe way to check for them ? |
Other constraints, like UNIQUE, PRIMARY KEY, FOREIGN KEY and CREATE INDEX can only be ensured on the database side. Which constraint did you have in mind? |
Fixed with Release 2.8.0. |
Describe the bug
A clear and concise description of what the bug is.
if model has null.String fields INSERT panics with
panic: jet: null.String type can not be used as SQL query parameter
at internal/jet/sql_builder.go:238 due to
Environment (please complete the following information):
Code snippet
Expected behavior
null.String implements scanner and valuer interfaces. insert should work
The text was updated successfully, but these errors were encountered: