def test_cols_concat(self): self._test_cols( self.hashcol.concat(hstore(cast(self.test_table.c.id, Text), '3')), ("test_table.hash || hstore(CAST(test_table.id AS TEXT), " "%(param_1)s) AS anon_1"), True )
def test_cols_hstore_pair_array(self): self._test_cols( hstore(array(['1', '2']), array(['3', None]))['1'], ("hstore(ARRAY[%(param_1)s, %(param_2)s], " "ARRAY[%(param_3)s, NULL]) -> %(hstore_1)s AS anon_1"), False )
def test_cols_hstore_single_array(self): self._test_cols( hstore(array(['1', '2', '3', None]))['3'], ("hstore(ARRAY[%(param_1)s, %(param_2)s, %(param_3)s, NULL]) " "-> %(hstore_1)s AS anon_1"), False )
def test_cols_delete_matching_pairs(self): self._test_cols( self.hashcol.delete(hstore('1', '2')), ("delete(test_table.hash, hstore(%(param_1)s, %(param_2)s)) " "AS delete_1"), True )
hashcol = test_table.c.hash where_tests = [ hashcol.has_key('foo'), hashcol.has_all(array(['foo', 'bar'])), hashcol.has_any(array(['baz', 'foo'])), hashcol.defined('bar'), hashcol.contains({'foo': '1'}), hashcol.contained_by({'foo': '1', 'bar': None}), hashcol['bar'] == None, ] select_tests = [ hashcol['foo'], hashcol.delete('foo'), hashcol.delete(array(['foo', 'bar'])), hashcol.delete(hstore('bar', None)), hashcol.delete({'bar': None}), hashcol.slice(array(['foo', 'bar'])), hstore('foo', '3')['foo'], hstore('foo', None)['foo'], hstore('bar', 'baz')['foo'], hstore(array(['1', '2']), array(['3', '4']))['1'], hstore(array(['1', '2', '3', '4']))['3'], hashcol + hstore(sql.cast(test_table.c.id, Text), '3'), hashcol + hashcol, (hashcol + hashcol)['foo'], hashcol.keys(), hashcol.vals(), hashcol.array(), hashcol.matrix(), sql.func.sum(sql.cast(hashcol['foo'], Integer)),
def test_cols_hstore_pair_text(self): self._test_cols( hstore('foo', '3')['foo'], "hstore(%(param_1)s, %(param_2)s) -> %(hstore_1)s AS anon_1", False )
print 's.dirty:', s.dirty print s.commit() queries = [ s.query(Test).filter(Test.hash.has_key('foo')), s.query(Test).filter(Test.hash.has_all(array(['foo', 'bar']))), s.query(Test).filter(Test.hash.has_any(array(['baz', 'foo']))), s.query(Test).filter(Test.hash.defined('bar')), s.query(Test).filter(Test.hash.contains({'foo': '1'})), s.query(Test).filter(Test.hash.contained_by({'foo': '1', 'bar': None})), s.query(Test).filter(Test.hash['bar'] == None), s.query(Test.hash['foo']), s.query(Test.hash.delete('foo')), s.query(Test.hash.delete(array(['foo', 'bar']))), s.query(Test.hash.delete(hstore('bar', None))), s.query(Test.hash.delete({'bar': None})), s.query(Test.hash.slice(array(['foo', 'bar']))), s.query(hstore('foo', '3')['foo']), s.query(hstore('foo', None)['foo']), s.query(hstore('bar', 'baz')['foo']), s.query(hstore(array(['1', '2']), array(['3', '4']))['1']), s.query(hstore(array(['1', '2', '3', '4']))['3']), s.query(Test.hash + hstore(sql.cast(Test.id, Text), '3')), s.query(Test.hash + Test.hash), s.query((Test.hash + Test.hash)['foo']), s.query(Test.hash.keys()), s.query(Test.hash.vals()), s.query(Test.hash.array()), s.query(Test.hash.matrix()), s.query(sql.func.sum(sql.cast(Test.hash['foo'], Integer))),
hashcol.has_key('foo'), hashcol.has_all(array(['foo', 'bar'])), hashcol.has_any(array(['baz', 'foo'])), hashcol.defined('bar'), hashcol.contains({'foo': '1'}), hashcol.contained_by({ 'foo': '1', 'bar': None }), hashcol['bar'] == None, ] select_tests = [ hashcol['foo'], hashcol.delete('foo'), hashcol.delete(array(['foo', 'bar'])), hashcol.delete(hstore('bar', None)), hashcol.delete({'bar': None}), hashcol.slice(array(['foo', 'bar'])), hstore('foo', '3')['foo'], hstore('foo', None)['foo'], hstore('bar', 'baz')['foo'], hstore(array(['1', '2']), array(['3', '4']))['1'], hstore(array(['1', '2', '3', '4']))['3'], hashcol + hstore(sql.cast(test_table.c.id, Text), '3'), hashcol + hashcol, (hashcol + hashcol)['foo'], hashcol.keys(), hashcol.vals(), hashcol.array(), hashcol.matrix(), sql.func.sum(sql.cast(hashcol['foo'], Integer)),
queries = [ s.query(Test).filter(Test.hash.has_key('foo')), s.query(Test).filter(Test.hash.has_all(array(['foo', 'bar']))), s.query(Test).filter(Test.hash.has_any(array(['baz', 'foo']))), s.query(Test).filter(Test.hash.defined('bar')), s.query(Test).filter(Test.hash.contains({'foo': '1'})), s.query(Test).filter(Test.hash.contained_by({ 'foo': '1', 'bar': None })), s.query(Test).filter(Test.hash['bar'] == None), s.query(Test.hash['foo']), s.query(Test.hash.delete('foo')), s.query(Test.hash.delete(array(['foo', 'bar']))), s.query(Test.hash.delete(hstore('bar', None))), s.query(Test.hash.delete({'bar': None})), s.query(Test.hash.slice(array(['foo', 'bar']))), s.query(hstore('foo', '3')['foo']), s.query(hstore('foo', None)['foo']), s.query(hstore('bar', 'baz')['foo']), s.query(hstore(array(['1', '2']), array(['3', '4']))['1']), s.query(hstore(array(['1', '2', '3', '4']))['3']), s.query(Test.hash + hstore(sql.cast(Test.id, Text), '3')), s.query(Test.hash + Test.hash), s.query((Test.hash + Test.hash)['foo']), s.query(Test.hash.keys()), s.query(Test.hash.vals()), s.query(Test.hash.array()), s.query(Test.hash.matrix()), s.query(sql.func.sum(sql.cast(Test.hash['foo'], Integer))),