-
Notifications
You must be signed in to change notification settings - Fork 48
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
ExecuteSql() does not support any kind of nil/null values. #29
Comments
You can Scan nullable varchar into *string type. Here is the example.
|
Scan maybe does work (i think it really does), but this issue is about passing nil *string to conn.ExecuteSql :-) The parameter was converted to something NVARCHAR(x), 'NULL', instead of NVARCHAR(x), NULL and the query crashed on that. |
Sorry, |
I have made a small PR for the fix: #75
I don't know for sure. Based on this code it seems For my use case (sybase 12.5) it doesn't need the type so I know my change works there. |
Using sql.NullString (or custom NullTime which implements driver.Valuer interface (methods Value, Scan)) as a parameter to ExecuteSql results in SQL error. Using *time.Time, *string, etc. results in the same error:
This happens when I try to use datetime passed by user in the query. The query looks like this:
Which my custom QueryWithNamedParameters will conver to this:
and then I pass my NullTime type to the query, expecting it to behave like this:
but it doesn't and results in the error above.
I'm currently trying to work around this issue by patching executesql.go, function "go2SqlDataType" like this, which works:
... but I don't know if passing "nvarchar(4), NULL" is a good idea. Does the type of the parameter matter if the value is NULL?
The text was updated successfully, but these errors were encountered: