Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def _test_db_opt_unpresent(self, url_string, key):
        import cx_Oracle

        url_obj = url.make_url(url_string)
        dialect = cx_oracle.dialect(dbapi=cx_Oracle)
        arg, kw = dialect.create_connect_args(url_obj)
        assert key not in kw
Exemplo n.º 4
0
    def test_encoding_errors_cx_oracle(
        self,
        cx_Oracle,
        cx_oracle_type,
    ):
        ignore_dialect = cx_oracle.dialect(dbapi=cx_Oracle,
                                           encoding_errors="ignore")

        ignore_outputhandler = (
            ignore_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()
        ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)

        eq_(
            cursor.mock_calls,
            [
                mock.call.var(
                    mock.ANY,
                    None,
                    cursor.arraysize,
                    encodingErrors="ignore",
                )
            ],
        )
Exemplo n.º 5
0
    def test_no_encoding_errors_cx_oracle(
        self,
        cx_Oracle,
        cx_oracle_type,
    ):
        plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)

        plain_outputhandler = (
            plain_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()
        plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)

        if cx_oracle_type in (cx_Oracle.FIXED_CHAR, cx_Oracle.STRING):
            # no calls; without encodingErrors, use cx_Oracle's default unicode
            # handling
            eq_(
                cursor.mock_calls,
                [],
            )
        else:
            eq_(
                cursor.mock_calls,
                [mock.call.var(mock.ANY, None, cursor.arraysize)],
            )
Exemplo n.º 6
0
    def test_no_encoding_errors_cx_oracle_py3k(self, cx_Oracle, cx_oracle_type,
                                               use_read):
        plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)

        plain_outputhandler = (
            plain_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()
        plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)

        if use_read:
            eq_(
                cursor.mock_calls,
                [
                    mock.call.var(mock.ANY,
                                  None,
                                  cursor.arraysize,
                                  outconverter=mock.ANY)
                ],
            )
        else:
            eq_(
                cursor.mock_calls,
                [mock.call.var(mock.ANY, None, cursor.arraysize)],
            )
Exemplo n.º 7
0
    def _test_db_opt(self, url_string, key, value):
        import cx_Oracle

        url_obj = url.make_url(url_string)
        dialect = cx_oracle.dialect(dbapi=cx_Oracle)
        arg, kw = dialect.create_connect_args(url_obj)
        eq_(kw[key], value)
Exemplo n.º 8
0
    def _test_db_opt_unpresent(self, url_string, key):
        import cx_Oracle

        url_obj = url.make_url(url_string)
        dialect = cx_oracle.dialect(dbapi=cx_Oracle)
        arg, kw = dialect.create_connect_args(url_obj)
        assert key not in kw
Exemplo n.º 9
0
 def test_threaded_deprecated_at_dialect_level(self):
     with testing.expect_deprecated(
             "The 'threaded' parameter to the cx_oracle dialect"):
         dialect = cx_oracle.dialect(threaded=False)
     arg, kw = dialect.create_connect_args(
         url.make_url("oracle+cx_oracle://scott:tiger@dsn"))
     eq_(kw["threaded"], False)
Exemplo n.º 10
0
    def _test_db_opt(self, url_string, key, value):
        import cx_Oracle

        url_obj = url.make_url(url_string)
        dialect = cx_oracle.dialect(dbapi=cx_Oracle)
        arg, kw = dialect.create_connect_args(url_obj)
        eq_(kw[key], value)
Exemplo n.º 11
0
 def test_bindparam_quote_raise_on_expanding(self):
     assert_raises_message(
         exc.CompileError,
         "Can't use expanding feature with parameter name 'uid' on "
         "Oracle; it requires quoting which is not supported in this "
         "context",
         bindparam("uid", expanding=True).compile,
         dialect=cx_oracle.dialect())
Exemplo n.º 12
0
 def test_bindparam_quote_raise_on_expanding(self):
     assert_raises_message(
         exc.CompileError,
         "Can't use expanding feature with parameter name 'uid' on "
         "Oracle; it requires quoting which is not supported in this "
         "context",
         bindparam("uid", expanding=True).compile,
         dialect=cx_oracle.dialect(),
     )
Exemplo n.º 13
0
 def test_threaded_deprecated_at_dialect_level(self):
     with testing.expect_deprecated(
         "The 'threaded' parameter to the cx_oracle dialect"
     ):
         dialect = cx_oracle.dialect(threaded=False)
     arg, kw = dialect.create_connect_args(
         url.make_url("oracle+cx_oracle://scott:tiger@dsn")
     )
     eq_(kw["threaded"], False)
Exemplo n.º 14
0
    def test_no_encoding_errors_sqla_py2k(self, cx_Oracle, cx_oracle_type,
                                          use_read):
        plain_dialect = cx_oracle.dialect(dbapi=cx_Oracle)

        plain_outputhandler = (
            plain_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()
        plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
        outconverter = cursor.mock_calls[0][2]["outconverter"]
        self._assert_errorhandler(outconverter, use_read, False)
Exemplo n.º 15
0
    def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type):
        cx_Oracle.version = "6.3"

        with testing.expect_warnings(
            r"cx_oracle version \(6, 3\) does not support encodingErrors"
        ):
            dialect = cx_oracle.dialect(
                dbapi=cx_Oracle, encoding_errors="ignore"
            )

            eq_(dialect._cursor_var_unicode_kwargs, {})
Exemplo n.º 16
0
    def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type):
        cx_Oracle.version = "6.3"

        ignore_dialect = cx_oracle.dialect(dbapi=cx_Oracle,
                                           encoding_errors="ignore")
        ignore_outputhandler = (
            ignore_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()

        with testing.expect_warnings(
                r"cx_oracle version \(6, 3\) does not support encodingErrors"):
            ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None,
                                 None)
Exemplo n.º 17
0
    def test_encoding_errors_sqla_py2k(
        self,
        cx_Oracle,
        cx_oracle_type,
    ):
        ignore_dialect = cx_oracle.dialect(dbapi=cx_Oracle,
                                           encoding_errors="ignore")

        ignore_outputhandler = (
            ignore_dialect._generate_connection_outputtype_handler())

        cursor = mock.Mock()
        ignore_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
        outconverter = cursor.mock_calls[0][2]["outconverter"]
        self._assert_errorhandler(outconverter, True)
Exemplo n.º 18
0
    def test_type_adapt(self):
        dialect = cx_oracle.dialect()

        for start, test in [
            (Date(), cx_oracle._OracleDate),
            (oracle.OracleRaw(), cx_oracle._OracleRaw),
            (String(), String),
            (VARCHAR(), VARCHAR),
            (String(50), String),
            (Unicode(), Unicode),
            (Text(), cx_oracle._OracleText),
            (UnicodeText(), cx_oracle._OracleUnicodeText),
            (NCHAR(), cx_oracle._OracleNVarChar),
            (oracle.RAW(50), cx_oracle._OracleRaw),
        ]:
            assert isinstance(start.dialect_impl(dialect), test), "wanted %r got %r" % (test, start.dialect_impl(dialect))
Exemplo n.º 19
0
    def test_type_adapt_nchar(self):
        dialect = cx_oracle.dialect(use_nchar_for_unicode=True)

        for start, test in [
            (String(), String),
            (VARCHAR(), cx_oracle._OracleString),
            (String(50), cx_oracle._OracleString),
            (Unicode(), cx_oracle._OracleUnicodeStringNCHAR),
            (Text(), cx_oracle._OracleText),
            (UnicodeText(), cx_oracle._OracleUnicodeTextNCLOB),
            (NCHAR(), cx_oracle._OracleUnicodeStringNCHAR),
            (NVARCHAR(), cx_oracle._OracleUnicodeStringNCHAR),
        ]:
            assert isinstance(
                start.dialect_impl(dialect),
                test), "wanted %r got %r" % (test, start.dialect_impl(dialect))
Exemplo n.º 20
0
    def test_type_adapt_nchar(self):
        dialect = cx_oracle.dialect(use_nchar_for_unicode=True)

        for start, test in [
            (String(), String),
            (VARCHAR(), cx_oracle._OracleString),
            (String(50), cx_oracle._OracleString),
            (Unicode(), cx_oracle._OracleUnicodeStringNCHAR),
            (Text(), cx_oracle._OracleText),
            (UnicodeText(), cx_oracle._OracleUnicodeTextNCLOB),
            (NCHAR(), cx_oracle._OracleUnicodeStringNCHAR),
            (NVARCHAR(), cx_oracle._OracleUnicodeStringNCHAR),
        ]:
            assert isinstance(
                start.dialect_impl(dialect), test
            ), "wanted %r got %r" % (test, start.dialect_impl(dialect))
    def test_type_adapt(self):
        dialect = cx_oracle.dialect()

        for start, test in [
            (Date(), cx_oracle._OracleDate),
            (oracle.OracleRaw(), cx_oracle._OracleRaw),
            (String(), String),
            (VARCHAR(), cx_oracle._OracleString),
            (DATE(), DATE),
            (String(50), cx_oracle._OracleString),
            (Unicode(), cx_oracle._OracleNVarChar),
            (Text(), cx_oracle._OracleText),
            (UnicodeText(), cx_oracle._OracleUnicodeText),
            (NCHAR(), cx_oracle._OracleNVarChar),
            (oracle.RAW(50), cx_oracle._OracleRaw),
        ]:
            assert isinstance(start.dialect_impl(dialect), test), \
                    "wanted %r got %r" % (test, start.dialect_impl(dialect))
Exemplo n.º 22
0
    def test_type_adapt(self, start, test):
        dialect = cx_oracle.dialect()

        assert isinstance(
            start.dialect_impl(dialect), test
        ), "wanted %r got %r" % (test, start.dialect_impl(dialect))
Exemplo n.º 23
0
    def test_type_adapt_nchar(self, start, test):
        dialect = cx_oracle.dialect(use_nchar_for_unicode=True)

        assert isinstance(
            start.dialect_impl(dialect), test
        ), "wanted %r got %r" % (test, start.dialect_impl(dialect))
Exemplo n.º 24
0
 def test_bindparam_quote_works_on_expanding(self):
     self.assert_compile(
         bindparam("uid", expanding=True),
         "([POSTCOMPILE_uid])",
         dialect=cx_oracle.dialect(),
     )