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

invalid Enum error while parsing single value enum with zero value #1434

Open
1 task
topofstack opened this issue Nov 14, 2024 · 0 comments
Open
1 task

invalid Enum error while parsing single value enum with zero value #1434

topofstack opened this issue Nov 14, 2024 · 0 comments
Assignees

Comments

@topofstack
Copy link

Observed

When parsing enum type with a single value, function extractEnumNamedValues works incorrectly, returning valid==false for single-value enum with zero value:

_, _, _, valid := extractEnumNamedValues("Enum8('FOO' = 0)")
fmt.Println(valid) // false

The output is correct if two or more enum values are passed:

_, _, _, valid := extractEnumNamedValues("Enum8('FOO' = 0, 'BAR' = 1")
fmt.Println(valid) // true

or value is not zero:

_, _, _, valid := extractEnumNamedValues("Enum8('FOO' = 1")
fmt.Println(valid) // true

Details

Looks like we need to add additional check here https://github.com/ClickHouse/clickhouse-go/blob/v2.30.0/lib/column/enum.go#L169

// Enum type must have at least one value
if valueIndex == 0 && !indexFound{
		return
}

Environment

  • clickhouse-go v2.30.0
@topofstack topofstack changed the title invalid Enum error while parsin single value enum with zero value invalid Enum error while parsing single value enum with zero value Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants