Example #1
0
    def test_render_alias_in_array_sql(self):
        tb = Table("tb")

        q = PostgreSQLQuery.from_(tb).select(
            Array(tb.col).as_("different_name"))
        self.assertEqual(str(q),
                         'SELECT ARRAY["col"] "different_name" FROM "tb"')
Example #2
0
    def test_array_general(self):
        query = Query.from_(self.table_abc) \
            .select(Array(1, 'a', ['b', 2, 3]))

        self.assertEqual('SELECT [1,\'a\',[\'b\',2,3]] FROM "abc"', str(query))
        self.assertEqual('SELECT [1,\'a\',[\'b\',2,3]] FROM "abc"',
                         str(query.get_sql()))
Example #3
0
    def test_array_postgresql(self):
        query = PostgreSQLQuery.from_(self.table_abc).select(
            Array(1, "a", ["b", 2, 3]))

        self.assertEqual("SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"abc\"",
                         str(query))
        self.assertEqual("SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"abc\"",
                         query.get_sql())
Example #4
0
    def test_array_postgresql(self):
        query = PostgreSQLQuery.from_(self.table_abc) \
            .select(Array(1, 'a', ['b', 2, 3]))

        self.assertEqual('SELECT ARRAY[1,\'a\',ARRAY[\'b\',2,3]] FROM "abc"',
                         str(query))
        self.assertEqual('SELECT ARRAY[1,\'a\',ARRAY[\'b\',2,3]] FROM "abc"',
                         query.get_sql())
Example #5
0
    def test_array_syntax(self):
        tb = Table("tb")
        q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3]))

        self.assertEqual(str(q),
                         "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"")
Example #6
0
    def test_array_general(self):
        query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3]))

        self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query))
Example #7
0
    def test_psql_array_general(self):
        query = PostgreSQLQuery.from_(self.table_abc).select(
            Array(1, Array(2, 2, 2), 3))

        self.assertEqual('SELECT ARRAY[1,ARRAY[2,2,2],3] FROM "abc"',
                         str(query))
Example #8
0
    def test_empty_psql_array(self):
        query = PostgreSQLQuery.from_(self.table_abc).select(Array())

        self.assertEqual("SELECT '{}' FROM \"abc\"", str(query))