from the association table by a delete operation matches the expected
results
- session.get() and session.load() propigate **kwargs through to query
+ - fix to polymorphic query which allows the original polymorphic_union
+ to be embedded into a correlated subquery [ticket:577]
- mysql
- support for column-level CHARACTER SET and COLLATE declarations,
as well as ASCII, UNICODE, NATIONAL and BINARY shorthand.
# adapt the given WHERECLAUSE to adjust instances of this query's mapped
# table to be that of our select_table,
# which may be the "polymorphic" selectable used by our mapper.
- sql_util.ClauseAdapter(self.table).traverse(whereclause)
+ sql_util.ClauseAdapter(self.table).traverse(whereclause, stop_on=util.Set([self.table]))
# if extra entities, adapt the criterion to those as well
for m in self._entities:
m = mapper.class_mapper(m)
if isinstance(m, mapper.Mapper):
table = m.select_table
- sql_util.ClauseAdapter(m.select_table).traverse(whereclause)
+ sql_util.ClauseAdapter(m.select_table).traverse(whereclause, stop_on=util.Set([m.select_table]))
# get/create query context. get the ultimate compile arguments
# from there
# it has no relations() on it. should we compile those too into the query ? (i.e. eagerloads)
for value in self.select_mapper.props.values():
value.setup(context)
-
+
# additional entities/columns, add those to selection criterion
for m in self._entities:
if isinstance(m, type):
session.save(dead)
session.flush()
+ # TODO: we haven't created assertions for all the data combinations created here
+
# creating 5 managers named from M1 to M5 and 5 engineers named from E1 to E5
# M4, M5, E4 and E5 are dead
for i in range(1,5):
session.save(car2)
session.flush()
- # test these twice because theres caching involved
+ # test these twice because theres caching involved, as well previous issues that modified the polymorphic union
for x in range(0, 2):
r = session.query(Person).filter_by(people.c.name.like('%2')).join('status').filter_by(name="active")
assert str(list(r)) == "[Manager M2, category YYYYYYYYY, status Status active, Engineer E2, field X, status Status active]"
r = session.query(Engineer).join('status').filter(people.c.name.in_('E2', 'E3', 'E4', 'M4', 'M2', 'M1') & (status.c.name=="active"))
assert str(list(r)) == "[Engineer E2, field X, status Status active, Engineer E3, field X, status Status active]"
+ # this test embeds the original polymorphic union (employee_join) fully
+ # into the WHERE criterion, using a correlated select. ticket #577 tracks
+ # that Query's adaptation of the WHERE clause does not dig into the
+ # mapped selectable itself, which permanently breaks the mapped selectable.
+ r = session.query(Person).filter(Car.c.owner == select([Car.c.owner], Car.c.owner==employee_join.c.person_id))
+ assert str(list(r)) == "[Engineer E4, field X, status Status dead]"
class MultiLevelTest(testbase.ORMTest):
def define_tables(self, metadata):