Skip to content
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

Fix ascii marshal, unmarshall #322

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

illia-li
Copy link

@illia-li illia-li commented Oct 27, 2024

Changes:

  1. Unmarshalling zero data into []byte, *[]byte, returned ([]byte)(nil) and (*[]byte)(*[nil]) before, now returns ([]byte)([]) and (*[]byte)(*[])
  2. Unmarshalling into *custom interface{}, was unsupported before, now is supported.
  3. Unmarshalling data with bytes out of the range 0-127, does not return an error before, now return an error.

marshal.go Outdated Show resolved Hide resolved
dkropachev
dkropachev previously approved these changes Oct 30, 2024
serialization/ascii/unmarshal_utils.go Outdated Show resolved Hide resolved
dkropachev
dkropachev previously approved these changes Nov 7, 2024
@dkropachev
Copy link
Collaborator

@illia-li , can you please rebase it

debounce/simple_debouncer_test.go Outdated Show resolved Hide resolved
serialization/ascii/marshal.go Show resolved Hide resolved
}
v.SetBytes(decBytes(p))
case reflect.Interface:
v.Elem().Set(reflect.ValueOf(decBytes(p)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure that ascii, by default, should be serialized into string not into []byte

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text, blob, varchar cql types unmarshalls *interface{} as []byte

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any logic in old marshal that would inmarshal to interface, but here is the default behavior when it prepares rows:

func goType(t TypeInfo) (reflect.Type, error) {
	switch t.Type() {
	case TypeVarchar, TypeAscii, TypeInet, TypeText:
		return reflect.TypeOf(*new(string)), nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants