- 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]
+ - fix to select_by(<propname>=<object instance>) -style joins in conjunction
+ with many-to-many relationships, bug introduced in r2556
- mysql
- support for column-level CHARACTER SET and COLLATE declarations,
as well as ASCII, UNICODE, NATIONAL and BINARY shorthand.
if logging.is_info_enabled(self.logger):
self.logger.info(str(self) + " setup primary join " + str(self.primaryjoin))
self.logger.info(str(self) + " setup polymorphic primary join " + str(self.polymorphic_primaryjoin))
+ self.logger.info(str(self) + " setup secondary join " + str(self.secondaryjoin))
+ self.logger.info(str(self) + " setup polymorphic secondary join " + str(self.polymorphic_secondaryjoin))
self.logger.info(str(self) + " foreign keys " + str([str(c) for c in self.foreign_keys]))
self.logger.info(str(self) + " remote columns " + str([str(c) for c in self.remote_side]))
self.logger.info(str(self) + " relation direction " + (self.direction is sync.ONETOMANY and "one-to-many" or (self.direction is sync.MANYTOONE and "many-to-one" or "many-to-many")))
reverse = {}
def should_bind(targetcol, othercol):
- if reverse_direction:
+ if reverse_direction and not secondaryjoin:
return targetcol in remote_side
else:
return othercol in remote_side
lazywhere = primaryjoin.copy_container()
li = mapperutil.BinaryVisitor(visit_binary)
- li.traverse(lazywhere)
+
+ if not secondaryjoin or not reverse_direction:
+ li.traverse(lazywhere)
if secondaryjoin is not None:
secondaryjoin = secondaryjoin.copy_container()
+ if reverse_direction:
+ li.traverse(secondaryjoin)
lazywhere = sql.and_(lazywhere, secondaryjoin)
if hasattr(cls, 'parent_property'):
self.assert_result(k, Keyword, *item_keyword_result[1]['keywords'][1])
- def testjoinvia(self):
- """test the join_via and join_to functions"""
+ def testautojoin(self):
+ """test functions derived from Query's _join_to function."""
m = mapper(User, users, properties={
'orders':relation(mapper(Order, orders, properties={
assert False
except AttributeError:
assert True
-
- def testjoinviam2m(self):
- """test the join_via and join_to functions"""
+ def testautojoinm2m(self):
+ """test functions derived from Query's _join_to function."""
+
m = mapper(Order, orders, properties = {
'items' : relation(mapper(Item, orderitems, properties = {
'keywords' : relation(mapper(Keyword, keywords), itemkeywords)
l = q.filter(keywords.c.name=='square').join(['items', 'keywords']).list()
self.assert_result(l, Order, order_result[1])
+ # test comparing to an object instance
+ item = sess.query(Item).selectfirst()
+ l = sess.query(Item).select_by(keywords=item.keywords[0])
+ assert item == l[0]
def testcustomjoin(self):
"""test that the from_obj parameter to query.select() can be used
to totally replace the FROM parameters of the generated query."""
+
m = mapper(User, users, properties={
'orders':relation(mapper(Order, orders, properties={
'items':relation(mapper(Item, orderitems))