Esempio n. 1
0
    def test_try_cast(self):
        metadata = MetaData()
        t1 = Table("t1", metadata, Column("id", Integer, primary_key=True))

        self.assert_compile(
            select([try_cast(t1.c.id, Integer)]),
            "SELECT TRY_CAST (t1.id AS INTEGER) AS id FROM t1",
        )
Esempio n. 2
0
    def test_try_cast(self):
        engine = engines.testing_engine()
        metadata = self.metadata
        t1 = Table(
            "t1",
            metadata,
            Column("id", Integer, primary_key=True),
            implicit_returning=False,
        )
        metadata.create_all(engine)

        with self.sql_execution_asserter(engine) as asserter:
            engine.execute(t1.select([try_cast(t1.id, Integer)]))

        asserter.assert_(CursorSQL("SELECT TRY_CAST(id AS Integer) FROM t1"), )