Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Enum type values not reflected #904

Open
1 task done
joouha opened this issue Feb 14, 2024 · 0 comments
Open
1 task done

[Bug]: Enum type values not reflected #904

joouha opened this issue Feb 14, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@joouha
Copy link

joouha commented Feb 14, 2024

What happened?

Hello,

When reflecting a duckdb column with an enum datatype, are the enum's values supposed to get populated in the column's type?

If I create a table with an enum type column:

CREATE TYPE color_enum AS ENUM ('red', 'blue', 'green');
CREATE TABLE ducks (
    id INTEGER,
    color color_enum
);

When loading this column in sqlalchemy, the columns type is set to an empty Enum type:

>>> from sqlalchemy import create_engine, inspect
... engine = create_engine("duckdb:///db.db")
... inspect(engine).get_columns("ducks")

[{'name': 'id',
  'type': INTEGER(),
  'nullable': True,
  'default': None,
  'autoincrement': False,
  'comment': None},
 {'name': 'color',
  'type': Enum(),
  'nullable': True,
  'default': None,
  'autoincrement': False,
  'comment': None}]

The enum values are readable using the get_enums method:

>>> inspect(engine).get_enums()

[{'name': 'color_enum',
          'schema': 'main',
          'visible': True,
          'labels': ['red', 'blue', 'green']}]

I was expecting the sqlalchemy column types to be automatically populated with the enum values from the DB.

Thanks!

DuckDB Engine Version

duckdb_engine==0.11.1

DuckDB Version

duckdb==0.10.0

SQLAlchemy Version

SQLAlchemy==2.0.27

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@joouha joouha added the bug Something isn't working label Feb 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants