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
feat(spanner): allow untyped nil values in parameterized queries #4482
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,12 @@ func TestConvertParams(t *testing.T) { | |
listProto(listProto(intProto(10)), listProto(intProto(20))), | ||
listType(structType(mkField("field", intType()))), | ||
}, | ||
// Untyped null | ||
{ | ||
nil, | ||
nullProto(), | ||
nil, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious: would this work? Because it expects a *sppb.Type but we give nothing, e.g.,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this test it would fail, as the test will verify that the param type is not set (or set to nil). That comparison will fail if we set it to
|
||
}, | ||
} { | ||
st.Params["var"] = test.val | ||
gotParams, gotParamTypes, gotErr := st.convertParams() | ||
|
@@ -179,23 +185,6 @@ func TestConvertParams(t *testing.T) { | |
t.Errorf("%#v: got %v, want %v\n", test.val, gotParamType, test.wantField) | ||
} | ||
} | ||
|
||
// Verify type error reporting. | ||
for _, test := range []struct { | ||
val interface{} | ||
wantErr error | ||
}{ | ||
{ | ||
nil, | ||
errBindParam("var", nil, errNilParam), | ||
}, | ||
} { | ||
st.Params["var"] = test.val | ||
_, _, gotErr := st.convertParams() | ||
if !testEqual(gotErr, test.wantErr) { | ||
t.Errorf("value %#v:\ngot: %v\nwant: %v", test.val, gotErr, test.wantErr) | ||
} | ||
} | ||
} | ||
|
||
func TestNewStatement(t *testing.T) { | ||
|
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.
Shouldn't this be
!isEmulatorEnvSet()
if the emulator env is not set?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.
Yep 👍