Ejemplo n.º 1
0
 def test_count(self):
     ss = SelectStatement('table', count=True, limit=10, order_by='d')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(
         six.text_type(ss),
         'SELECT COUNT(*) FROM table WHERE "a" = %(0)s LIMIT 10',
         six.text_type(ss))
     self.assertIn('LIMIT', six.text_type(ss))
     self.assertNotIn('ORDER', six.text_type(ss))
Ejemplo n.º 2
0
    def test_context_id_update(self):
        """ tests that the right things happen the the context id """
        ss = SelectStatement("table")
        ss.add_where_clause(WhereClause("a", EqualsOperator(), "b"))
        self.assertEqual(ss.get_context(), {"0": "b"})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = :0')

        ss.update_context_id(5)
        self.assertEqual(ss.get_context(), {"5": "b"})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = :5')
Ejemplo n.º 3
0
    def test_context_id_update(self):
        """ tests that the right things happen the the context id """
        ss = SelectStatement('table')
        ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
        self.assertEqual(ss.get_context(), {'0': 'b'})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = %(0)s')

        ss.update_context_id(5)
        self.assertEqual(ss.get_context(), {'5': 'b'})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = %(5)s')
Ejemplo n.º 4
0
    def test_context_id_update(self):
        """ tests that the right things happen the the context id """
        ss = SelectStatement('table')
        ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
        self.assertEqual(ss.get_context(), {'0': 'b'})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = %(0)s')

        ss.update_context_id(5)
        self.assertEqual(ss.get_context(), {'5': 'b'})
        self.assertEqual(str(ss), 'SELECT * FROM table WHERE "a" = %(5)s')
Ejemplo n.º 5
0
 def test_context(self):
     ss = SelectStatement("table")
     ss.add_where_clause(WhereClause("a", EqualsOperator(), "b"))
     self.assertEqual(ss.get_context(), {"0": "b"})
Ejemplo n.º 6
0
 def test_count(self):
     ss = SelectStatement("table", count=True, limit=10, order_by="d")
     ss.add_where_clause(WhereClause("a", EqualsOperator(), "b"))
     self.assertEqual(unicode(ss), 'SELECT COUNT(*) FROM table WHERE "a" = :0', unicode(ss))
     self.assertNotIn("LIMIT", unicode(ss))
     self.assertNotIn("ORDER", unicode(ss))
Ejemplo n.º 7
0
 def test_where_clause_rendering(self):
     ss = SelectStatement("table")
     ss.add_where_clause(WhereClause("a", EqualsOperator(), "b"))
     self.assertEqual(unicode(ss), 'SELECT * FROM table WHERE "a" = :0', unicode(ss))
Ejemplo n.º 8
0
 def test_context(self):
     ss = SelectStatement('table')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(ss.get_context(), {'0': 'b'})
Ejemplo n.º 9
0
 def test_where_clause_rendering(self):
     ss = SelectStatement('table')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(six.text_type(ss),
                      'SELECT * FROM table WHERE "a" = %(0)s',
                      six.text_type(ss))
Ejemplo n.º 10
0
 def test_context(self):
     ss = SelectStatement('table')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(ss.get_context(), {'0': 'b'})
Ejemplo n.º 11
0
 def test_count(self):
     ss = SelectStatement('table', count=True, limit=10, order_by='d')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(unicode(ss), 'SELECT COUNT(*) FROM table WHERE "a" = %(0)s LIMIT 10', unicode(ss))
     self.assertIn('LIMIT', unicode(ss))
     self.assertNotIn('ORDER', unicode(ss))
Ejemplo n.º 12
0
 def test_where_clause_rendering(self):
     ss = SelectStatement('table')
     ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
     self.assertEqual(unicode(ss), 'SELECT * FROM table WHERE "a" = %(0)s', unicode(ss))