def class_getTupleWhere(klass, opTuple, order=(), limit=0, offset=0, **kw): """ Retrieve objects using Lisp-like queries Allows you to use a somewhat Lispish notation for generating SQL queries, like so: obj.getTupleWhere(('OR', ('LIKE', FIELD('last_name'), 'Ingers%'), ('OR', ('<>', FIELD('id'), 355), ('=', FIELD('id'), 356)))) Strings are used to represent operators rather than the SQLOperator class wrappers used in getSomeWhere(), but the FIELD and SET classes are still useful. The kw argument is treated the same as in getSome() and getSomeWhere(). """ kw = klass._convertKW(kw) if kw: _and=opTuple and ['AND', opTuple] or [] for k, v in kw.items(): _and.append(('=', FIELD(k), v)) opTuple=tuple(_and) sql=opTuple and operators.tupleToSQL(opTuple) or '' order_list=[] if order: if type(order) == types.StringType: order_list.append(order) else: order_list.extend(order) return klass.getSQLWhere(sql, order=order_list, limit=limit, offset=offset)
def static_getTupleWhere(self, opTuple, **kw): if kw: _and=opTuple and ['AND', opTuple] or [] for k, v in kw.items(): _and.append(('=', FIELD(k), v)) opTuple=tuple(_and) sql=opTuple and operators.tupleToSQL(opTuple) or '' return self.getSQLWhere(sql)
def class_getTupleWhere(klass, opTuple, **kw): if kw: _and = opTuple and ["AND", opTuple] or [] for k, v in kw.items(): _and.append(("=", FIELD(k), v)) opTuple = tuple(_and) sql = opTuple and operators.tupleToSQL(opTuple) or "" return klass.getSQLWhere(sql)
def static_getTupleWhere(self, opTuple, **kw): if kw: _and = opTuple and ['AND', opTuple] or [] for k, v in kw.items(): _and.append(('=', FIELD(k), v)) opTuple = tuple(_and) sql = opTuple and operators.tupleToSQL(opTuple) or '' return self.getSQLWhere(sql)
def static_getTupleWhere(self, opTuple, order=(), limit=0, offset=0, **kw): if kw: _and=opTuple and ['AND', opTuple] or [] for k, v in kw.items(): if k not in ('order', 'limit', 'offset'): _and.append(('=', operators.FIELD(k), v)) opTuple=tuple(_and) sql=opTuple and operators.tupleToSQL(opTuple) or '' order_list=[] if order: if type(order) == types.StringType: order_list.append(order) else: order_list.extend(order) return self.getSQLWhere(sql, order=order_list, limit=limit, offset=offset)
def class_getTupleWhere(klass, opTuple, order=(), limit=0, offset=0, **kw): """ Retrieve objects using Lisp-like queries Allows you to use a somewhat Lispish notation for generating SQL queries, like so: obj.getTupleWhere(('OR', ('LIKE', FIELD('last_name'), 'Ingers%'), ('OR', ('<>', FIELD('id'), 355), ('=', FIELD('id'), 356)))) Strings are used to represent operators rather than the SQLOperator class wrappers used in getSomeWhere(), but the FIELD and SET classes are still useful. The kw argument is treated the same as in getSome() and getSomeWhere(). """ kw = klass._convertKW(kw) if kw: _and = opTuple and ['AND', opTuple] or [] for k, v in kw.items(): _and.append(('=', FIELD(k), v)) opTuple = tuple(_and) sql = opTuple and operators.tupleToSQL(opTuple) or '' order_list = [] if order: if type(order) == types.StringType: order_list.append(order) else: order_list.extend(order) return klass.getSQLWhere(sql, order=order_list, limit=limit, offset=offset)