You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In certain circumstances, when querying a table with an Enum column an error is thrown:
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 393, in _raw_all_rows
return [make_row(row) for row in rows]
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 393, in
return [make_row(row) for row in rows]
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/sql/sqltypes.py", line 1768, in process
value = parent_processor(value)
TypeError: expected bytes, str found
To Reproduce
Create a table with a clickhouse_sqlalchemy.types.Enum field
Fill it with data
SELECT some data from it via SQLAlchemy
Expected behavior
The same code worked correctly on SQLAlchemy 1.3 and it was expected for it to continue that way.
After this change, String.result_processor method will invoke processors.to_conditional_unicode_processor_factory() instead of processors.to_unicode_processor_factory() to obtain the result converting function.
Method 2: in addition to the above, assign:
engine.dialect.convert_unicode=False
This will mean that no conversion at all will happen because SQLAlchemy will expect to receive proper Unicode strings from the driver. This should provide a bit higher performance.
Describe the bug
In certain circumstances, when querying a table with an
Enum
column an error is thrown:To Reproduce
clickhouse_sqlalchemy.types.Enum
fieldSELECT
some data from it via SQLAlchemyExpected behavior
The same code worked correctly on SQLAlchemy 1.3 and it was expected for it to continue that way.
How to fix
Method 1:
After this change,
String.result_processor
method will invokeprocessors.to_conditional_unicode_processor_factory()
instead ofprocessors.to_unicode_processor_factory()
to obtain the result converting function.Method 2: in addition to the above, assign:
This will mean that no conversion at all will happen because SQLAlchemy will expect to receive proper Unicode strings from the driver. This should provide a bit higher performance.
Versions
Python: 3.8.12.
Libraries:
The text was updated successfully, but these errors were encountered: