summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-03-03 09:30:58 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-03-04 23:22:20 -0500
commitb38fb59fe484d6e4e5992c9b2dc9b9f7724f016a (patch)
tree21bac11da9981fe45b20bdb06240b37fb47b5800 /test/dialect
parent7099dd20e90307237240f30d5db0816a08356a5b (diff)
downloadsqlalchemy-b38fb59fe484d6e4e5992c9b2dc9b9f7724f016a.tar.gz
audition pymssql once more; retire sane_rowcount_returning
pymssql seems to be maintained again and seems to be working completely, so let's try re-enabling it. Fixed issue in the new :class:`.Uuid` datatype which prevented it from working with the pymssql driver. As pymssql seems to be maintained again, restored testing support for pymssql. Tweaked the pymssql dialect to take better advantage of RETURNING for INSERT statements in order to retrieve last inserted primary key values, in the same way as occurs for the mssql+pyodbc dialect right now. Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now compatible with the SQLAlchemy ORM's "versioned rows" feature, since SQLAlchemy now computes rowcount for a RETURNING statement in this specific case by counting the rows returned, rather than relying upon ``cursor.rowcount``. In particular, the ORM versioned rows use case (documented at :ref:`mapper_version_counter`) should now be fully supported with the SQL Server pyodbc dialect. Change-Id: I38a0666587212327aecf8f98e86031ab25d1f14d References: #5321 Fixes: #9414
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/mssql/test_query.py4
-rw-r--r--test/dialect/mssql/test_types.py33
2 files changed, 35 insertions, 2 deletions
diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py
index b65e27445..35575bc13 100644
--- a/test/dialect/mssql/test_query.py
+++ b/test/dialect/mssql/test_query.py
@@ -18,6 +18,7 @@ from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy import testing
from sqlalchemy.dialects.mssql import base as mssql
+from sqlalchemy.dialects.mssql import pyodbc as mssql_pyodbc
from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import config
from sqlalchemy.testing import engines
@@ -409,7 +410,7 @@ def full_text_search_missing():
return result.scalar() == 0
-class MatchTest(fixtures.TablesTest, AssertsCompiledSQL):
+class MatchTest(AssertsCompiledSQL, fixtures.TablesTest):
__only_on__ = "mssql"
__skip_if__ = (full_text_search_missing,)
@@ -517,6 +518,7 @@ class MatchTest(fixtures.TablesTest, AssertsCompiledSQL):
self.assert_compile(
matchtable.c.title.match("somstr"),
"CONTAINS (matchtable.title, ?)",
+ dialect=mssql_pyodbc.dialect(paramstyle="qmark"),
)
def test_simple_match(self, connection):
diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py
index 867e42202..cb7ed3102 100644
--- a/test/dialect/mssql/test_types.py
+++ b/test/dialect/mssql/test_types.py
@@ -815,7 +815,36 @@ class TypeRoundTripTest(
)
return t, (d1, t1, d2, d3)
- def test_date_roundtrips(self, date_fixture, connection):
+ def test_date_roundtrips_no_offset(self, date_fixture, connection):
+ t, (d1, t1, d2, d3) = date_fixture
+ connection.execute(
+ t.insert(),
+ dict(
+ adate=d1,
+ adatetime=d2,
+ atime1=t1,
+ atime2=d2,
+ ),
+ )
+
+ row = connection.execute(t.select()).first()
+ eq_(
+ (
+ row.adate,
+ row.adatetime,
+ row.atime1,
+ row.atime2,
+ ),
+ (
+ d1,
+ d2,
+ t1,
+ d2.time(),
+ ),
+ )
+
+ @testing.skip_if("+pymssql", "offsets dont seem to work")
+ def test_date_roundtrips_w_offset(self, date_fixture, connection):
t, (d1, t1, d2, d3) = date_fixture
connection.execute(
t.insert(),
@@ -855,6 +884,7 @@ class TypeRoundTripTest(
(datetime.datetime(2007, 10, 30, 11, 2, 32)),
argnames="date",
)
+ @testing.skip_if("+pymssql", "unknown failures")
def test_tz_present_or_non_in_dates(self, date_fixture, connection, date):
t, (d1, t1, d2, d3) = date_fixture
connection.execute(
@@ -954,6 +984,7 @@ class TypeRoundTripTest(
id_="iaaa",
argnames="dto_param_value, expected_offset_hours, should_fail",
)
+ @testing.skip_if("+pymssql", "offsets dont seem to work")
def test_datetime_offset(
self,
datetimeoffset_fixture,