Beispiel #1
0
 def condition(self):
     names = list(remote_column_names(self.prop))
     if len(names) == 1:
         attr = getattr(remote(self.prop), names[0])
         return attr.in_(
             mapfirst(list_local_values(self.prop, self.path.entities)))
     elif len(names) > 1:
         return sa.or_(
             *list_local_remote_exprs(self.prop, self.path.entities))
     else:
         raise PathException('Could not obtain remote column names.')
Beispiel #2
0
 def relation_query_base(self):
     return (
         self.path.session
         .query(
             self.path.model,
             *[
                 getattr(remote(self.prop), name)
                 for name in remote_column_names(self.prop)
             ]
         )
         .join(
             self.prop.secondary, self.prop.secondaryjoin
         )
     )
Beispiel #3
0
 def condition(self):
     names = list(remote_column_names(self.prop))
     if len(names) == 1:
         attr = getattr(remote(self.prop), names[0])
         return attr.in_(
             v[0] for v in list_local_values(self.prop, self.path.entities)
         )
     elif len(names) > 1:
         return sa.or_(
             *list_local_remote_exprs(self.prop, self.path.entities)
         )
     else:
         raise PathException(
             'Could not obtain remote column names.'
         )
Beispiel #4
0
 def relation_query_base(self):
     return (self.path.session.query(
         self.path.model, *[
             getattr(remote(self.prop), name)
             for name in remote_column_names(self.prop)
         ]).join(self.prop.secondary, self.prop.secondaryjoin))