File: test_deprecations.py

package info (click to toggle)
sqlalchemy 1.4.46%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,444 kB
  • sloc: python: 341,434; ansic: 1,760; makefile: 226; xml: 17; sh: 7
file content (40 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from sqlalchemy import select
from sqlalchemy import table
from sqlalchemy.dialects.mysql import base as mysql
from sqlalchemy.dialects.mysql import ENUM
from sqlalchemy.dialects.mysql import SET
from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import expect_deprecated
from sqlalchemy.testing import expect_deprecated_20
from sqlalchemy.testing import fixtures


class CompileTest(AssertsCompiledSQL, fixtures.TestBase):

    __dialect__ = mysql.dialect()

    def test_distinct_string(self):
        s = select("*").select_from(table("foo"))
        s._distinct = "foo"

        with expect_deprecated(
            "Sending string values for 'distinct' is deprecated in the MySQL "
            "dialect and will be removed in a future release"
        ):
            self.assert_compile(s, "SELECT FOO * FROM foo")


class DeprecateQuoting(fixtures.TestBase):
    def test_enum_warning(self):
        ENUM("a", "b")
        with expect_deprecated_20(
            "The 'quoting' parameter to :class:`.mysql.ENUM` is deprecated."
        ):
            ENUM("a", quoting="foo")

    def test_set_warning(self):
        SET("a", "b")
        with expect_deprecated_20(
            "The 'quoting' parameter to :class:`.mysql.SET` is deprecated.*"
        ):
            SET("a", quoting="foo")