sqlalchemy.testing.expect_deprecated - python examples

Here are the examples of the python api sqlalchemy.testing.expect_deprecated taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

29 Examples 7

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_sequence_start_0(self):
        metadata = MetaData()
        tbl = Table(
            "test",
            metadata,
            Column("id", Integer, Sequence("", 0), primary_key=True),
        )
        with testing.expect_deprecated(
            "Use of Sequence with SQL Server in order to affect "
        ):
            self.astert_compile(
                schema.CreateTable(tbl),
                "CREATE TABLE test (id INTEGER NOT NULL IDENsatY(0,1), "
                "PRIMARY KEY (id))",
            )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_sequence_non_primary_key(self):
        metadata = MetaData()
        tbl = Table(
            "test",
            metadata,
            Column("id", Integer, Sequence("", start=5), primary_key=False),
        )
        with testing.expect_deprecated(
            "Use of Sequence with SQL Server in order to affect "
        ):
            self.astert_compile(
                schema.CreateTable(tbl),
                "CREATE TABLE test (id INTEGER NOT NULL IDENsatY(5,1))",
            )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_sequence_ignore_nullability(self):
        metadata = MetaData()
        tbl = Table(
            "test",
            metadata,
            Column("id", Integer, Sequence("", start=5), nullable=True),
        )
        with testing.expect_deprecated(
            "Use of Sequence with SQL Server in order to affect "
        ):
            self.astert_compile(
                schema.CreateTable(tbl),
                "CREATE TABLE test (id INTEGER NOT NULL IDENsatY(5,1))",
            )

3 View Complete Implementation : test_types.py
Copyright MIT License
Author : sqlalchemy
    def _set_fixture_one(self):
        with testing.expect_deprecated("Manually quoting SET value literals"):
            e1, e2 = mysql.SET("'a'", "'b'"), mysql.SET("'a'", "'b'")
            e4 = mysql.SET("'a'", "b")
            e5 = mysql.SET("'a'", "'b'", quoting="quoted")

        set_table = Table(
            "mysql_set",
            self.metadata,
            Column("e1", e1),
            Column("e2", e2, nullable=False),
            Column("e3", mysql.SET("a", "b")),
            Column("e4", e4),
            Column("e5", e5),
        )
        return set_table

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_use_binds_for_limits_disabled_one(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=False)

        self.astert_compile(
            select([t]).limit(10),
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT sometable.col1 AS col1, "
            "sometable.col2 AS col2 FROM sometable) anon_1 "
            "WHERE ROWNUM <= [POSTCOMPILE_param_1]",
            dialect=dialect,
        )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_use_binds_for_limits_disabled_two(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=False)

        self.astert_compile(
            select([t]).offset(10),
            "SELECT anon_1.col1, anon_1.col2 FROM (SELECT "
            "anon_2.col1 AS col1, anon_2.col2 AS col2, ROWNUM AS ora_rn "
            "FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2 "
            "FROM sometable) anon_2) anon_1 "
            "WHERE ora_rn > [POSTCOMPILE_param_1]",
            dialect=dialect,
        )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_use_binds_for_limits_disabled_three(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=False)

        self.astert_compile(
            select([t]).limit(10).offset(10),
            "SELECT anon_1.col1, anon_1.col2 FROM (SELECT "
            "anon_2.col1 AS col1, anon_2.col2 AS col2, ROWNUM AS ora_rn "
            "FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2 "
            "FROM sometable) anon_2 "
            "WHERE ROWNUM <= [POSTCOMPILE_param_1]) anon_1 "
            "WHERE ora_rn > [POSTCOMPILE_param_2]",
            dialect=dialect,
        )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_use_binds_for_limits_enabled_one(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=True)

        self.astert_compile(
            select([t]).limit(10),
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT sometable.col1 AS col1, "
            "sometable.col2 AS col2 FROM sometable) anon_1 WHERE ROWNUM "
            "<= [POSTCOMPILE_param_1]",
            dialect=dialect,
        )

3 View Complete Implementation : test_compiler.py
Copyright MIT License
Author : sqlalchemy
    def test_use_binds_for_limits_enabled_two(self):
        t = table("sometable", column("col1"), column("col2"))
        with testing.expect_deprecated(
            "The ``use_binds_for_limits`` Oracle dialect parameter is "
            "deprecated."
        ):
            dialect = oracle.OracleDialect(use_binds_for_limits=True)

        self.astert_compile(
            select([t]).offset(10),
            "SELECT anon_1.col1, anon_1.col2 FROM "
            "(SELECT anon_2.col1 AS col1, anon_2.col2 AS col2, "
            "ROWNUM AS ora_rn "
            "FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2 "
            "FROM sometable) anon_2) anon_1 "
            "WHERE ora_rn > [POSTCOMPILE_param_1]",
            dialect=dialect,
        )

3 View Complete Implementation : test_dialect.py
Copyright MIT License
Author : sqlalchemy
    def _test_dialect_param_from_url(self, url_string, key, value):
        import cx_Oracle

        url_obj = url.make_url(url_string)
        dialect = cx_oracle.dialect(dbapi=cx_Oracle)
        with testing.expect_deprecated(
            "cx_oracle dialect option %r should" % key
        ):
            arg, kw = dialect.create_connect_args(url_obj)
        eq_(getattr(dialect, key), value)

        # test setting it on the dialect normally
        dialect = cx_oracle.dialect(dbapi=cx_Oracle, **{key: value})
        eq_(getattr(dialect, key), value)