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

Redo columnDef.UnmarshalJSON #353

Closed
dkropachev opened this issue Jun 11, 2023 · 3 comments
Closed

Redo columnDef.UnmarshalJSON #353

dkropachev opened this issue Jun 11, 2023 · 3 comments

Comments

@dkropachev
Copy link
Collaborator

As of now it has very clumsy unmarhsaling, let's make it work without retrying on every known columnType

func (cd *ColumnDef) UnmarshalJSON(data []byte) error {
	dataMap := make(map[string]interface{})
	if err := json.Unmarshal(data, &dataMap); err != nil {
		return err
	}

	t, err := GetSimpleTypeColumn(dataMap)
	if err != nil {
		t, err = GetUDTTypeColumn(dataMap)
		if err != nil {
			t, err = GetTupleTypeColumn(dataMap)
			if err != nil {
				t, err = GetMapTypeColumn(dataMap)
				if err != nil {
					t, err = GetBagTypeColumn(dataMap)
					if err != nil {
						return err
					}
				}
			}
		}
	}
	*cd = ColumnDef{
		Name: t.Name,
		Type: t.Type,
	}
	return nil
}

@illia-li
Copy link
Contributor

Impossible to accurately determine functional purpose of this function and there no it usage. What will be at it inputs (cd, data)? Needs some examples.

@dkropachev
Copy link
Collaborator Author

It is json.UnMarshal hook that is called, if present, to unmarshal data to the receiver type.
Here it is used to read schema file into gemini schema definition.
There is a bug #355 that depicts case when unmarshaling went wrong

@dkropachev
Copy link
Collaborator Author

Implemented at #360

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

No branches or pull requests

2 participants