mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-21 16:12:03 -04:00
Fixes: #5781 - fix bug with having criteria with adapters
This commit is contained in:
@@ -585,7 +585,7 @@ class ORMSelectCompileState(ORMCompileState, SelectState):
|
||||
|
||||
if query._having_criteria:
|
||||
self._having_criteria = tuple(
|
||||
current_adapter(crit, True, True) if current_adapter else crit
|
||||
current_adapter(crit, True) if current_adapter else crit
|
||||
for crit in query._having_criteria
|
||||
)
|
||||
|
||||
|
||||
@@ -654,6 +654,36 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
|
||||
Engineer(name="vlad", primary_language="cobol"),
|
||||
)
|
||||
|
||||
def test_single_having(self):
|
||||
"""test single table inheritance in combination with having"""
|
||||
|
||||
class Person(Base, fixtures.ComparableEntity):
|
||||
__tablename__ = "people"
|
||||
id = Column(
|
||||
Integer, primary_key=True, test_needs_autoincrement=True
|
||||
)
|
||||
name = Column(String(50))
|
||||
discriminator = Column("type", String(50))
|
||||
__mapper_args__ = {"polymorphic_on": discriminator}
|
||||
|
||||
class Engineer(Person):
|
||||
__mapper_args__ = {"polymorphic_identity": "engineer"}
|
||||
primary_language = Column(String(50))
|
||||
|
||||
Base.metadata.create_all()
|
||||
sess = create_session()
|
||||
e1 = Engineer(name="Sean", primary_language="js")
|
||||
sess.add(e1)
|
||||
sess.flush()
|
||||
sess.expunge_all()
|
||||
eq_(
|
||||
sess.query(Engineer)
|
||||
.group_by(Engineer.id)
|
||||
.having(Engineer.primary_language=="js")
|
||||
.first(),
|
||||
Engineer(name="Sean"),
|
||||
)
|
||||
|
||||
def test_single_cols_on_sub_base_of_joined(self):
|
||||
"""test [ticket:3895]"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user