def test_update_returning(): u = (UPDATE("table1").SET(col1='test').RETURNING('test', 'test1')) assert u.query == '\n'.join([ "UPDATE table1", " SET col1 = %(col1_bind)s", "RETURNING test, test1;" ])
def test_named_arg_update(): u = (UPDATE("table1").SET(col1='test').SET("col2 = 'test2'").WHERE(id=5)) expected = '\n'.join([ "UPDATE table1", " SET col1 = %(col1_bind)s,", " col2 = 'test2'", " WHERE id = %(id_bind_1)s;" ]) assert u.query == expected assert u.binds == {'col1_bind': 'test', 'id_bind_1': 5}
def test_update_one_row(): u = (UPDATE("table1").SET("col1 = 'test'").SET("col2 = 'test2'").WHERE( id=5)) expected = '\n'.join([ "UPDATE table1", " SET col1 = 'test',", " col2 = 'test2'", " WHERE id = %(id_bind_0)s;" ]) assert u.query == expected assert u.binds == {'id_bind_0': 5}
def test_simple_update(): u = (UPDATE("table1").SET("col1 = 'test'").SET("col2 = 'test2'")) expected = '\n'.join( ["UPDATE table1", " SET col1 = 'test',", " col2 = 'test2';"]) assert u.query == expected