summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-10-18 09:44:37 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-10-18 14:11:11 -0400
commitf4214975a7deb5e13f8b6cf21e39697821396a7f (patch)
treef4c3f6480812e12f8d833aed892b195349b18fed /lib/sqlalchemy/testing
parent665c94cc2f0340735515c4f4477e11b556d2bcd8 (diff)
downloadsqlalchemy-f4214975a7deb5e13f8b6cf21e39697821396a7f.tar.gz
further qualify pyodbc setinputsizes types for long stirngs
Fixed regression caused by SQL Server pyodbc change :ticket:`8177` where we now use ``setinputsizes()`` by default; for VARCHAR, this fails if the character size is greater than 4000 (or 2000, depending on data) characters as the incoming datatype is NVARCHAR, which has a limit of 4000 characters, despite the fact that VARCHAR can handle unlimited characters. Additional pyodbc-specific typing information is now passed to ``setinputsizes()`` when the datatype's size is > 2000 characters. The change is also applied to the :class:`.JSON` type which was also impacted by this issue for large JSON serializations. Fixes: #8661 Change-Id: I07fa873e95dbd2c94f3d286e93e8b3229c3a9807
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/config.py18
-rw-r--r--lib/sqlalchemy/testing/suite/test_types.py15
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/sqlalchemy/testing/config.py b/lib/sqlalchemy/testing/config.py
index 1cb463977..44133984b 100644
--- a/lib/sqlalchemy/testing/config.py
+++ b/lib/sqlalchemy/testing/config.py
@@ -12,10 +12,11 @@ from __future__ import annotations
import collections
import typing
from typing import Any
+from typing import Callable
from typing import Iterable
from typing import Optional
-from typing import overload
from typing import Tuple
+from typing import TypeVar
from typing import Union
from .. import util
@@ -39,16 +40,15 @@ else:
_fixture_functions = None # installed by plugin_base
-@overload
+_FN = TypeVar("_FN", bound=Callable[..., Any])
+
+
def combinations(
*comb: Union[Any, Tuple[Any, ...]],
argnames: Optional[str] = None,
id_: Optional[str] = None,
-):
- ...
-
-
-def combinations(*comb: Union[Any, Tuple[Any, ...]], **kw: str):
+ **kw: str,
+) -> Callable[[_FN], _FN]:
r"""Deliver multiple versions of a test based on positional combinations.
This is a facade over pytest.mark.parametrize.
@@ -111,7 +111,9 @@ def combinations(*comb: Union[Any, Tuple[Any, ...]], **kw: str):
"""
- return _fixture_functions.combinations(*comb, **kw)
+ return _fixture_functions.combinations(
+ *comb, id_=id_, argnames=argnames, **kw
+ )
def combinations_list(
diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py
index 9461298b9..25ed041c2 100644
--- a/lib/sqlalchemy/testing/suite/test_types.py
+++ b/lib/sqlalchemy/testing/suite/test_types.py
@@ -1148,6 +1148,21 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
def test_round_trip_data1(self, connection):
self._test_round_trip({"key1": "value1", "key2": "value2"}, connection)
+ @testing.combinations(
+ ("unicode", True), ("ascii", False), argnames="unicode_", id_="ia"
+ )
+ @testing.combinations(100, 1999, 3000, 4000, 5000, 9000, argnames="length")
+ def test_round_trip_pretty_large_data(self, connection, unicode_, length):
+
+ if unicode_:
+ data = "réve🐍illé" * ((length // 9) + 1)
+ data = data[0 : (length // 2)]
+ else:
+ data = "abcdefg" * ((length // 7) + 1)
+ data = data[0:length]
+
+ self._test_round_trip({"key1": data, "key2": data}, connection)
+
def _test_round_trip(self, data_element, connection):
data_table = self.tables.data_table