Skip to content

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

Open
@topofstack

Description

@topofstack

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions