Skip to content

Commit

Permalink
fix: update Map type for 1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause authored Oct 21, 2024
1 parent 5a031c8 commit 7574837
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion duckdb_engine/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql import sqltypes, type_api
from sqlalchemy.sql.type_api import TypeEngine
from packaging.version import Version
from sqlalchemy.types import BigInteger, Integer, SmallInteger, String

# INTEGER INT4, INT, SIGNED -2147483648 2147483647
# SMALLINT INT2, SHORT -32768 32767
# BIGINT INT8, LONG -9223372036854775808 9223372036854775807
(BigInteger, SmallInteger) # pure reexport

from . import duckdb_version

IS_GT_1 = Version(duckdb_version) > Version('1.0.0')


class UInt64(Integer):
pass
Expand Down Expand Up @@ -157,7 +162,10 @@ def bind_processor(
def result_processor(
self, dialect: Dialect, coltype: str
) -> Optional[Callable[[Optional[dict]], Optional[dict]]]:
return lambda value: dict(zip(value["key"], value["value"])) if value else {}
if IS_GT_1:
return lambda value: value
else:
return lambda value: dict(zip(value["key"], value["value"])) if value else {}


class Union(TypeEngine):
Expand Down

0 comments on commit 7574837

Please sign in to comment.