Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(docs): demonstrate literal_binds #819

Merged
merged 10 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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');"))

Check warning on line 435 in duckdb_engine/tests/test_basic.py

View check run for this annotation

Codecov / codecov/patch

duckdb_engine/tests/test_basic.py#L433-L435

Added lines #L433 - L435 were not covered by tests

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

Check warning on line 441 in duckdb_engine/tests/test_basic.py

View check run for this annotation

Codecov / codecov/patch

duckdb_engine/tests/test_basic.py#L437-L441

Added lines #L437 - L441 were not covered by tests

stmt = (

Check warning on line 443 in duckdb_engine/tests/test_basic.py

View check run for this annotation

Codecov / codecov/patch

duckdb_engine/tests/test_basic.py#L443

Added line #L443 was not covered by tests
select(date_part)
.select_from(test)
.group_by(date_part)
.compile(dialect=engine.dialect, compile_kwargs={"literal_binds": True})
)
conn.execute(stmt).fetchall()

Check warning on line 449 in duckdb_engine/tests/test_basic.py

View check run for this annotation

Codecov / codecov/patch

duckdb_engine/tests/test_basic.py#L449

Added line #L449 was not covered by tests