コード例 #1
0
 def test_two_expr_columns(self):
     col_a = sql_builder.GreaterThanValue(1)
     col_b = sql_builder.LessThanValue(2)
     sql, bind_vars = sql_builder.build_where_clause(
         column_value_pairs=[('col_a', col_a), ('col_b', col_b)])
     self.assertEqual(sql, 'col_a > %(col_a_1)s AND col_b < %(col_b_2)s')
     self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2=2))
コード例 #2
0
ファイル: sql_builder_test.py プロジェクト: haoqoo/vitess
 def test_two_expr_columns(self):
   col_a = sql_builder.GreaterThanValue(1)
   col_b = sql_builder.LessThanValue(2)
   sql, bind_vars = sql_builder.build_where_clause(
       column_value_pairs=[('col_a', col_a), ('col_b', col_b)])
   self.assertEqual(sql, 'col_a > %(col_a_1)s AND col_b < %(col_b_2)s')
   self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2=2))
コード例 #3
0
ファイル: sql_builder_test.py プロジェクト: hediehy/vitess
 def test_three_iterable_columns(self):
     sql, bind_vars = sql_builder.build_where_clause(
         column_value_pairs=[("col_a", [1]), ("col_b", (2, 3)), ("col_c", set([4, 5]))]
     )
     self.assertEqual(
         sql,
         "col_a IN (%(col_a_1)s) AND col_b IN (%(col_b_2)s, %(col_b_3)s) AND " "col_c IN (%(col_c_4)s, %(col_c_5)s)",
     )
     self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2=2, col_b_3=3, col_c_4=4, col_c_5=5))
コード例 #4
0
 def test_three_iterable_columns(self):
   sql, bind_vars = sql_builder.build_where_clause(
       column_value_pairs=[
           ('col_a', [1]), ('col_b', (2, 3)), ('col_c', set([4, 5]))])
   self.assertEqual(
       sql,
       'col_a IN (%(col_a_1)s) AND col_b IN (%(col_b_2)s, %(col_b_3)s) AND '
       'col_c IN (%(col_c_4)s, %(col_c_5)s)')
   self.assertEqual(
       bind_vars,
       dict(col_a_1=1, col_b_2=2, col_b_3=3, col_c_4=4, col_c_5=5))
コード例 #5
0
 def test_empty_iterable(self):
     sql, bind_vars = sql_builder.build_where_clause(
         column_value_pairs=[('col_a', [])])
     self.assertEqual(sql, '1 = 0')
     self.assertEqual(bind_vars, dict(col_a=[]))
コード例 #6
0
 def test_two_simple_columns(self):
     sql, bind_vars = sql_builder.build_where_clause(
         column_value_pairs=[('col_a', 1), ('col_b', 'two')])
     self.assertEqual(sql, 'col_a = %(col_a_1)s AND col_b = %(col_b_2)s')
     self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2='two'))
コード例 #7
0
ファイル: sql_builder_test.py プロジェクト: haoqoo/vitess
 def test_empty_iterable(self):
   sql, bind_vars = sql_builder.build_where_clause(
       column_value_pairs=[('col_a', [])])
   self.assertEqual(sql, '1 = 0')
   self.assertEqual(bind_vars, dict(col_a=[]))
コード例 #8
0
ファイル: sql_builder_test.py プロジェクト: haoqoo/vitess
 def test_two_simple_columns(self):
   sql, bind_vars = sql_builder.build_where_clause(
       column_value_pairs=[('col_a', 1), ('col_b', 'two')])
   self.assertEqual(sql, 'col_a = %(col_a_1)s AND col_b = %(col_b_2)s')
   self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2='two'))
コード例 #9
0
ファイル: sql_builder_test.py プロジェクト: hediehy/vitess
 def test_two_expr_columns(self):
     col_a = sql_builder.Greater(1)
     col_b = sql_builder.Less(2)
     sql, bind_vars = sql_builder.build_where_clause(column_value_pairs=[("col_a", col_a), ("col_b", col_b)])
     self.assertEqual(sql, "col_a > %(col_a_1)s AND col_b < %(col_b_2)s")
     self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2=2))
コード例 #10
0
ファイル: sql_builder_test.py プロジェクト: hediehy/vitess
 def test_two_simple_columns(self):
     sql, bind_vars = sql_builder.build_where_clause(column_value_pairs=[("col_a", 1), ("col_b", "two")])
     self.assertEqual(sql, "col_a = %(col_a_1)s AND col_b = %(col_b_2)s")
     self.assertEqual(bind_vars, dict(col_a_1=1, col_b_2="two"))