-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support PROTO, ENUM #182
Support PROTO, ENUM #182
Conversation
I am wondering that |
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.
Thank you for filing this PR. I left a comment about how spanner-cli should handle the proto column. Let's discuss in the comment.
decoder_test.go
Outdated
@@ -330,6 +372,64 @@ func TestDecodeColumn(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestDecodeColumnProto(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.
Do we need these test cases?
I think spanner-cli should handle the proto column just as an arbitrary byte sequences (similar to BYTE
column) and I'm not sure if we should take care of the validness of the parsed content (I feel it's a job for Spanner server test case).
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.
Thank you. It is a fair comment.
This is a legacy of trying to put this test case into a table-driven test for TestDecodeColumn
.
What we really want to test here is the following:
- No error occurs
- It is not mistakenly treated as NULL or an empty byte string
- The input byte sequence does not change
Therefore, this test should simply test that the byte string is passed as is via spanner.GenericColumnValue
.
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.
I think it is what we need.
8752da0
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.
I have noticed it can be written by table driven test using spanner.GenericColumnValue
.
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.
rewrited af031a4
If you don't want to contain |
Sorry I don't have enough time to review this. Next ETA: end of this week. |
Sorry for the delayed review.
This is another approach, but how about using existing enum type which implements This is just for testing, so I think any enum is fine. |
decoder_test.go
Outdated
@@ -330,6 +370,56 @@ func TestDecodeColumn(t *testing.T) { | |||
} | |||
} | |||
|
|||
// It should only contain test cases which can't be tested in TestDecodeColumn | |||
func TestDecodeColumnGCV(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.
I think we don't need to create a separate test function because spanner.NewRow
accepts the spanner.GenericColumnValue
as well.
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.
I think that I don't want to test spanner.NewRow
and (*spanner.Row).Column
, so TestDecodeColumnGCV
is more cleaner unit tests.
But I don't want to rewrite all existing test cases in TestDecodeColumn
to equivalent hand written spanner.GenericColumnValue
, so I agree to merge new test cases into TestDecodeColumn
.
decoder_test.go
Outdated
{ | ||
desc: "null proto", | ||
value: (*protos.SingerInfo)(nil), | ||
want: "NULL", | ||
}, |
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.
Maybe we can replace this with the following test to stop dependency on the imported proto?
{
desc: "null proto",
value: spanner.GenericColumnValue{
Type: &sppb.Type{
Code: sppb.TypeCode_PROTO,
},
Value: structpb.NewNullValue(),
},
want: "NULL",
},
All options can test we want to test. |
I leave |
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.
LGTM. Thank you for your work on this PR! I think now the implementation is much clearer.
This PR adds decoder logic for
PROTO
andENUM
.Update dependency because it depends on "spanner: Add support for Proto Columns" in spanner client v1.62.0
fixes #174