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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: distinct doesn't work as a column wrapper #275
Changes from 2 commits
5e4074d
e6cf91a
b48be49
c40a921
e194ded
b09b636
4edafa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,3 +691,37 @@ def test_has_table(engine, engine_using_test_dataset, bigquery_dataset): | |
assert engine_using_test_dataset.has_table(f"{bigquery_dataset}.sample") is True | ||
|
||
assert engine_using_test_dataset.has_table("sample_alt") is False | ||
|
||
|
||
def test_distinct_188(engine, bigquery_dataset, metadata): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right you are! I'll remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy import Column, Integer | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
Base = declarative_base() | ||
|
||
class MyTable(Base): | ||
__tablename__ = f"{bigquery_dataset}.test_distinct_188" | ||
id = Column(Integer, primary_key=True) | ||
my_column = Column(Integer) | ||
|
||
MyTable.__table__.create(engine) | ||
|
||
Session = sessionmaker(bind=engine) | ||
db = Session() | ||
db.add_all([MyTable(id=i, my_column=i % 2) for i in range(9)]) | ||
db.commit() | ||
|
||
expected = [(0,), (1,)] | ||
|
||
assert sorted(db.query(MyTable.my_column).distinct().all()) == expected | ||
assert ( | ||
sorted( | ||
db.query( | ||
sqlalchemy.distinct(MyTable.my_column).label("just_a_random_label") | ||
).all() | ||
) | ||
== expected | ||
) | ||
|
||
assert sorted(db.query(sqlalchemy.distinct(MyTable.my_column)).all()) == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue open for addressing that gap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment is part of the copy from sqlalchemy. I'll delete it. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done