Skip to content

Commit

Permalink
fix: set div_is_floordiv to False to avoid bad casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause authored Jan 8, 2025
1 parent 5bf8a59 commit dfbed6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion duckdb_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class Dialect(PGDialect_psycopg2):
supports_comments = has_comment_support()
supports_sane_rowcount = False
supports_server_side_cursors = False
div_is_floordiv = False # TODO: tweak this to be based on DuckDB version
inspector = DuckDBInspector
# colspecs TODO: remap types to duckdb types
colspecs = util.update_copy(
PGDialect.colspecs,
{
Expand Down
12 changes: 11 additions & 1 deletion duckdb_engine/tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session
from sqlalchemy.sql import sqltypes
from sqlalchemy.types import JSON
from sqlalchemy.types import FLOAT, JSON

from .._supports import duckdb_version, has_uhugeint_support
from ..datatypes import Map, Struct, types
Expand Down Expand Up @@ -238,3 +238,13 @@ def test_interval(engine: Engine, snapshot: SnapshotTest) -> None:
test_table = Table("test_table", MetaData(), Column("duration", Interval))

assert "duration INTERVAL" in str(schema.CreateTable(test_table).compile(engine))


def test_div_is_floordiv(engine: Engine) -> None:
test_table = Table(
"test_table", MetaData(), Column("value", FLOAT), Column("eur2usd_rate", FLOAT)
)

stmt = test_table.c.value / test_table.c.eur2usd_rate

assert str(stmt.compile(engine)) == "test_table.value / test_table.eur2usd_rate"

0 comments on commit dfbed6d

Please sign in to comment.