-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Describe the bug
When converting SQL DDL that contains enums with whitespaces, omm creates invalid Python syntax.
E.g. the following SQL
CREATE TYPE "enum_with_spaces" AS ENUM (
'some value',
'another value'
);
Creates this Python output which contains illegal whitespace in the class attributes.
class EnumWithSpaces(str, Enum):
another value = 'another value'
some value = 'some value'
Expected behavior
The package should create valid Python code, since enums including whitespace are allowed in SQL and supported by Pythons enum package.
Proposed solution
As outlined in this blog post, the Enum
function allows us to specify member names using tuple lists or dicts. This way we can use names with spaces, and the above example can be re-written as:
EnumWithSpaces = Enum(
value='EnumWithSpaces',
names=[
('another value', 'another value'),
('some value', 'some value')
]
)
I'll create a PR including the proposed solution!
Metadata
Metadata
Assignees
Labels
No labels