Skip to content

Commit

Permalink
Merge pull request #819 from Mause/bugfix/issue-361
Browse files Browse the repository at this point in the history
chore(docs): demonstrate literal_binds
  • Loading branch information
Mause authored Nov 30, 2023
2 parents e47c870 + 42b95e1 commit 719b6f5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions duckdb_engine/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
String,
Table,
create_engine,
func,
inspect,
select,
text,
Expand Down Expand Up @@ -426,3 +427,23 @@ def test_params(engine: Engine) -> None:
s = text("SELECT :x")
with engine.connect() as conn:
assert ("m",) == conn.execute(s, {"x": "m"}).fetchone()


def test_361(engine: Engine) -> None:
with engine.connect() as conn:
conn.execute(text("create table test (dt date);"))
conn.execute(text("insert into test values ('2022-01-01');"))

metadata = MetaData()
metadata.reflect(bind=conn)
test = metadata.tables["test"]
part = "year"
date_part = func.date_part(part, test.c.dt)

stmt = (
select(date_part)
.select_from(test)
.group_by(date_part)
.compile(dialect=engine.dialect, compile_kwargs={"literal_binds": True})
)
conn.execute(stmt).fetchall()

0 comments on commit 719b6f5

Please sign in to comment.