Пример #1
0
 def filter(self, filter_clause):
     if filter_clause is None:
         # None doesn't filter anything, it's just a no-op:
         return self
     clause = self.clause
     if isinstance(clause, basestring):
         clause = sqlbuilder.SQLConstant('(%s)' % clause)
     return self.newClause(sqlbuilder.AND(clause, filter_clause))
Пример #2
0
 def _throughToRelatedJoin(self, join):
     otherClass = join.otherClass
     intTable = sqlbuilder.Table(join.intermediateTable)
     colName = join.joinColumn
     query = self.queryForSelect().newItems([sqlbuilder.ColumnAS(self.sourceClass.q.id, 'id')]).orderBy(None).distinct()
     query = sqlbuilder.Alias(query, "%s_%s" % (self.sourceClass.__name__, join.joinMethodName))
     clause = sqlbuilder.AND(otherClass.q.id == getattr(intTable, join.otherColumn),
                  getattr(intTable, colName) == query.q.id)
     return otherClass, clause
Пример #3
0
 def performJoin(self, inst):
     if inst.sqlmeta._perConnection:
         conn = inst._connection
     else:
         conn = None
     results = self.otherClass.select(sqlbuilder.AND(
         OtherTableToJoin(
             self.otherClass.sqlmeta.table, self.otherClass.sqlmeta.idName,
             self.intermediateTable, self.otherColumn
         ),
         JoinToTable(
             self.soClass.sqlmeta.table, self.soClass.sqlmeta.idName,
             self.intermediateTable, self.joinColumn
         ),
         TableToId(self.soClass.sqlmeta.table, self.soClass.sqlmeta.idName, inst.id),
     ), clauseTables=(self.soClass.sqlmeta.table, self.otherClass.sqlmeta.table, self.intermediateTable),
     connection=conn)
     return results.orderBy(self.orderBy)