Beispiel #1
0
    def test_create_table_nested_types(self):
        table = Table('t1', self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      Column('y', types.Array(types.String)), engines.Memory())

        self.assertEqual(
            self.compile(CreateTable(table)), 'CREATE TABLE t1 '
            '(x Int32, y Array(String)) '
            'ENGINE = Memory')

        table = Table('t1', self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      Column('y', types.Array(types.Array(types.String))),
                      engines.Memory())

        self.assertEqual(
            self.compile(CreateTable(table)), 'CREATE TABLE t1 '
            '(x Int32, y Array(Array(String))) '
            'ENGINE = Memory')

        table = Table('t1', self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      Column('y', types.Array(types.Array(types.String))),
                      engines.Memory())

        self.assertEqual(
            self.compile(CreateTable(table)), 'CREATE TABLE t1 '
            '(x Int32, y Array(Array(String))) '
            'ENGINE = Memory')
Beispiel #2
0
 def test_array(self):
     self.assertEqual(
         self.compile(types.Array(types.Int32())),
         'Array(Int32)'
     )
     self.assertEqual(
         self.compile(types.Array(types.Array(types.Int32()))),
         'Array(Array(Int32))'
     )
Beispiel #3
0
 def test_lambda_functions(self):
     query = session.query(
         func.arrayFilter(
             Lambda(lambda x: x.like('%World%')),
             literal(['Hello', 'abc World'], types.Array(types.String))
         ).label('test')
     )
     self.assertEqual(
         self.compile(query, literal_binds=True),
         "SELECT arrayFilter("
         "x -> x LIKE '%%World%%', ['Hello', 'abc World']"
         ") AS test"
     )