Python sqlalchemy.dialects.firebird.base.dialect() Examples

The following are 5 code examples of sqlalchemy.dialects.firebird.base.dialect(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.dialects.firebird.base , or try the search function .
Example #1
Source File: test_firebird.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_alias(self):
        t = table("sometable", column("col1"), column("col2"))
        s = select([t.alias()])
        self.assert_compile(
            s,
            "SELECT sometable_1.col1, sometable_1.col2 "
            "FROM sometable AS sometable_1",
        )
        dialect = firebird.FBDialect()
        dialect._version_two = False
        self.assert_compile(
            s,
            "SELECT sometable_1.col1, sometable_1.col2 "
            "FROM sometable sometable_1",
            dialect=dialect,
        ) 
Example #2
Source File: test_firebird.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_varchar_raise(self):
        for type_ in (
            String,
            VARCHAR,
            String(),
            VARCHAR(),
            Unicode,
            Unicode(),
        ):
            type_ = sqltypes.to_instance(type_)
            assert_raises_message(
                exc.CompileError,
                "VARCHAR requires a length on dialect firebird",
                type_.compile,
                dialect=firebird.dialect(),
            )

            t1 = Table("sometable", MetaData(), Column("somecolumn", type_))
            assert_raises_message(
                exc.CompileError,
                r"\(in table 'sometable', column 'somecolumn'\)\: "
                r"(?:N)?VARCHAR requires a length on dialect firebird",
                schema.CreateTable(t1).compile,
                dialect=firebird.dialect(),
            ) 
Example #3
Source File: test_firebird.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_column_computed_raises(self, persisted):
        m = MetaData()
        t = Table(
            "t",
            m,
            Column("x", Integer),
            Column("y", Integer, Computed("x + 2", persisted=persisted)),
        )
        assert_raises_message(
            exc.CompileError,
            "Firebird computed columns do not support a persistence method",
            schema.CreateTable(t).compile,
            dialect=firebird.dialect(),
        ) 
Example #4
Source File: test_firebird.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_version_parsing(self):
        for string, result in [
            ("WI-V1.5.0.1234 Firebird 1.5", (1, 5, 1234, "firebird")),
            ("UI-V6.3.2.18118 Firebird 2.1", (2, 1, 18118, "firebird")),
            ("LI-V6.3.3.12981 Firebird 2.0", (2, 0, 12981, "firebird")),
            ("WI-V8.1.1.333", (8, 1, 1, "interbase")),
            ("WI-V8.1.1.333 Firebird 1.5", (1, 5, 333, "firebird")),
        ]:
            eq_(testing.db.dialect._parse_version_info(string), result) 
Example #5
Source File: test_firebird.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_rowcount_flag(self):
        metadata = self.metadata
        engine = engines.testing_engine(options={"enable_rowcount": True})
        assert engine.dialect.supports_sane_rowcount
        metadata.bind = engine
        t = Table("t1", metadata, Column("data", String(10)))
        metadata.create_all()
        r = t.insert().execute({"data": "d1"}, {"data": "d2"}, {"data": "d3"})
        r = t.update().where(t.c.data == "d2").values(data="d3").execute()
        eq_(r.rowcount, 1)
        r = t.delete().where(t.c.data == "d3").execute()
        eq_(r.rowcount, 2)
        r = t.delete().execution_options(enable_rowcount=False).execute()
        eq_(r.rowcount, -1)
        engine.dispose()
        engine = engines.testing_engine(options={"enable_rowcount": False})
        assert not engine.dialect.supports_sane_rowcount
        metadata.bind = engine
        r = t.insert().execute({"data": "d1"}, {"data": "d2"}, {"data": "d3"})
        r = t.update().where(t.c.data == "d2").values(data="d3").execute()
        eq_(r.rowcount, -1)
        r = t.delete().where(t.c.data == "d3").execute()
        eq_(r.rowcount, -1)
        r = t.delete().execution_options(enable_rowcount=True).execute()
        eq_(r.rowcount, 1)
        r.close()
        engine.dispose()