Skip to content

Commit

Permalink
chore: replace with reproduction
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause authored Sep 13, 2022
1 parent d334cdb commit b643e27
Showing 1 changed file with 9 additions and 39 deletions.
48 changes: 9 additions & 39 deletions duckdb_engine/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,47 +340,17 @@ def test_do_ping(tmp_path: Path, caplog: LogCaptureFixture) -> None:


def test_361() -> None:
importorskip("sqlalchemy", "2.0.0")
importorskip("psycopg", "3.0.0")

from sqlalchemy import MetaData, create_engine, func, select, text
from sqlalchemy.engine import URL

url = URL.create(
"postgresql+psycopg",
username="gitpod",
password="gitpod",
host="localhost",
database="sammy",
)
engine = create_engine(url)
with engine.connect() as conn:
conn.execute(
text(
"create table if not exists test (dt date); insert into test values ('2022-01-01');"
)
)
conn.commit()

metadata = MetaData()
metadata.reflect(bind=engine)
# setup
conn = duckdb.connect("test.duckdb")
conn.execute("create table test (dt date); insert into test values ('2022-01-01');");

# query
engine = create_engine("duckdb:///test.duckdb")
metadata = MetaData(engine)
metadata.reflect()
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)

with engine.connect() as conn:
conn.execute(stmt).fetchall() # same exception


def test_361_psycopg():
psycopg = importorskip("psycopg")

with psycopg.connect(
"user=gitpod password=gitpod host=localhost dbname=sammy"
) as conn:
query = "SELECT date_part(%(date_part_2)s::VARCHAR, test.dt) AS date_part_1 \nFROM test GROUP BY date_part(%(date_part_2)s::VARCHAR, test.dt)"
effective_parameters = {"date_part_2": "year"}

conn.execute(query, effective_parameters)
engine.execute(stmt).fetchall()

0 comments on commit b643e27

Please sign in to comment.