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')
        class TestTable(base):
            __tablename__ = 'testtable'

            x = Column(types.Int32, primary_key=True)
            y = Column(types.String)

            __table_args__ = (engines.Memory(), )
Beispiel #3
0
    def test_sanity(self):
        table = Table(
            't1', self.metadata(),
            Column('x', types.Int32, primary_key=True),
            engines.Memory()
        )

        with mocked_engine(self.session) as engine:
            table.drop(if_exists=True)
            engine.assert_sql(['DROP TABLE IF EXISTS t1'])
Beispiel #4
0
    def test_create_table_nullable(self):
        table = Table('t1', self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      Column('y', types.Nullable(types.String)),
                      Column('z', types.Nullable(types.String(10))),
                      engines.Memory())

        self.assertEqual(
            self.compile(CreateTable(table)), 'CREATE TABLE t1 '
            '(x Int32, y Nullable(String), z Nullable(FixedString(10))) '
            'ENGINE = Memory')
Beispiel #5
0
    def test_create_table(self):
        table = Table('t1', self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      Column('y', types.String), Column('z', types.String(10)),
                      engines.Memory())

        # No NOT NULL. And any PKS.
        self.assertEqual(
            self.compile(CreateTable(table)),
            'CREATE TABLE t1 (x Int32, y String, z FixedString(10)) '
            'ENGINE = Memory')
Beispiel #6
0
    def test_escape_binary_mod(self):
        query = session.query(literal(1) % literal(2))
        self.assertEqual(
            self.compile(query, literal_binds=True),
            'SELECT 1 %% 2 AS anon_1'
        )

        table = Table(
            't', self.metadata(),
            Column('x', types.Int32, primary_key=True),
            engines.Memory()
        )

        query = session.query(table.c.x % table.c.x)
        self.assertEqual(
            self.compile(query, literal_binds=True),
            'SELECT x %% x AS anon_1 FROM t'
        )
Beispiel #7
0
        class TestTable(self.base):
            date = Column(types.Date, primary_key=True)
            x = Column(types.Int32)

            __table_args__ = (engines.Memory(), )