def test_condition_multi(self): names, values = ['first', 'last'], ['foo', 'bar'] conditions = [eq(name, value) for name, value in zip(names, values)] where = Where(*conditions) self.assertEquals(where.cql, ' AND '.join(cond.cql for cond in conditions)) self.assertEquals(where.values, values)
def get_query(self, assignment, condition, using=None): query = 'UPDATE {}'.format(self.column_family) if using: query = '{} {}'.format(query, using.cql) assignments = Assignments() assignments.add(assignment) where = Where(condition) return '{} SET {} WHERE {}'.format(query, assignments.cql, where.cql)
def test_condition_single(self): cond = eq('name', 'foo') where = Where(cond) self.assertEquals(where.cql, cond.cql) self.assertEquals(where.values, cond.values)
def where(self, *args): self.conditions = Where(*args) return self
def get_query(self, selection, condition=None): query = 'SELECT {} FROM {}'.format(selection.cql, self.column_family) if condition: where = Where(condition) query = '{} WHERE {}'.format(query, where.cql) return query