-
Notifications
You must be signed in to change notification settings - Fork 122
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
[SNOW-1669514] Honor the Valuer/Stringer methods to resolve #1209 #1211
base: master
Are you sure you want to change the base?
[SNOW-1669514] Honor the Valuer/Stringer methods to resolve #1209 #1211
Conversation
return bindingValue{}, nil | ||
} else if stringer, ok := v1.Interface().(fmt.Stringer); ok { // alternate approach; check for stringer method. Guarantees it's String() and returns string | ||
value := stringer.String() | ||
return bindingValue{&value, "", nil}, nil | ||
} | ||
res, err := json.Marshal(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this, the bindingValue is set to "json". Should that be the case, or should it be string? Since it is already Marshaled, why set it to json again? That will cause it to be marshaled a second time. It feels like it should not marshal here if it also sets the binding value to json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be clear This is in reference to the code on Lines 406-409; the added code will not return the "json"
string as it's already been transformed
// if the output value is a valid string, return that | ||
if strVal, ok := value.(string); ok { | ||
return bindingValue{&strVal, "", nil}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this here as a suggestion; did we want to let a marshaler handle the driver's value if not a string by default?
EDIT: The below suggestion would break sql.NullTime. Tests pass if we dont use the below suggestion. This is unless we don't want the expectation to be Epoch Time for this case?
} | |
} else if marshaled, err := json.Marshal(value); err == nil { | |
value := string(marshaled) | |
return bindingValue{&value, jsonFormatStr, nil}, nil | |
} |
@@ -28,6 +28,7 @@ import ( | |||
|
|||
const format = "2006-01-02 15:04:05.999999999" | |||
const numberDefaultPrecision = 38 | |||
const jsonFormatStr = "json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfc-gh-dszmolka can you please explain how the format string is being used by the execBindQuery
struct, or what is the purpose of this field?
Description
SNOW-1669514 - Solve the issue with UUID getting double quoted due to new array function #1209
This adds the ability to check the valuer/stringer interfaces exists
Checklist
Proof test fails.