-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow user-defined functions to accept pointers #729
Comments
@rittneje I've implemented this feature request tested it only briefly. Could you add a test case for this to About #728 This does not fix the issue with case #728 it only fixes "don't know how to convert to I hope you can write some nice |
@rittneje Code available in branch: |
Any updates on this? |
@clarkmcc I don't believe a PR was ever raised. And I don't think the branch from @gjrtimmer will work without further changes. It needs to be something along these lines: func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
switch typ.Kind() {
case reflect.Ptr:
f := callbackArg(typ.Elem())
return func(v *C.sqlite3_value) (reflect.Value, error) {
if C.sqlite3_value_type(v) == C.SQLITE_NULL {
return reflect.Zero(typ), nil
}
rv, err := f(v)
if err != nil {
return reflect.Value{}, err
}
ptr := reflect.New(rv.Type())
ptr.Elem().Set(rv)
return ptr, nil
}
... (Note: I have not tested or compiled this.) |
See #728. There the user had defined a function that took a
string
and SQLite tried to passNULL
to it. That resulted in an error from this library statingargument must be BLOB or TEXT
. Changing the function to take a*string
instead didn't work and resulted in an error statingdon't know how to convert to *string
. Please update the privatecallbackArg
func used byRegisterFunc
to properly handle an input type of kindreflect.Ptr
.The text was updated successfully, but these errors were encountered: