예제 #1
0
 def test_with_update_expr(self):
     sql, bind_vars = sql_builder.update_columns_query(
         table_name='my_table',
         where_column_value_pairs=[('col_a', 1), ('col_b', 2)],
         update_column_value_pairs=[('col_c', sql_builder.Increment(5))])
     self.assertEqual(
         sql,
         'UPDATE my_table SET col_c = (col_c + %(update_col_c_amount)s) '
         'WHERE col_a = %(col_a_1)s AND col_b = %(col_b_2)s')
     self.assertEqual(bind_vars,
                      dict(update_col_c_amount=5, col_a_1=1, col_b_2=2))
예제 #2
0
 def test_increment(self):
     increment = sql_builder.Increment(3)
     sql, bind_vars = increment.build_update_sql('col_a')
     self.assertEqual(sql, 'col_a = (col_a + %(update_col_a_amount)s)')
     self.assertEqual(bind_vars, dict(update_col_a_amount=3))