Skip to content

Commit eab50cc

Browse files
vistartclaude
andcommitted
fix(sqlserver): align dialect with core API changes and bump CI dependencies
- Change dialect __init__ default version from (16,0,0) to None, call super().__init__() first to enforce version adaptation via introspect_and_adapt() - Replace supports_returning_clause() with DML-specific supports_returning_insert/update/delete() (all True, OUTPUT clause) - Fix DEFAULT value escaping: use _escape_sql_string() instead of manual inline replace - Add constraint capability overrides: supports_constraint_enforced() (False), supports_fk_match() (False), supports_deferrable_constraint() (False) - Bump CI: activerecord to release/v1.0.0.dev27, testsuite to release/v1.0.0.dev14 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f9497a9 commit eab50cc

2 files changed

Lines changed: 48 additions & 24 deletions

File tree

.github/workflows/test.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
5959
- name: Install activerecord and testsuite from PyPI
6060
run: |
61-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
62-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
61+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
62+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
6363
6464
- name: Create test database
6565
run: |
@@ -147,8 +147,8 @@ jobs:
147147
148148
- name: Install activerecord and testsuite from PyPI
149149
run: |
150-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
151-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
150+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
151+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
152152
153153
- name: Create test database
154154
run: |
@@ -236,8 +236,8 @@ jobs:
236236
237237
- name: Install activerecord and testsuite from PyPI
238238
run: |
239-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
240-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
239+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
240+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
241241
242242
- name: Create test database
243243
run: |
@@ -325,8 +325,8 @@ jobs:
325325
326326
- name: Install activerecord and testsuite from PyPI
327327
run: |
328-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
329-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
328+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
329+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
330330
331331
- name: Create test database
332332
run: |
@@ -414,8 +414,8 @@ jobs:
414414
415415
- name: Install activerecord and testsuite from PyPI
416416
run: |
417-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
418-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
417+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
418+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
419419
420420
- name: Create test database
421421
run: |
@@ -503,8 +503,8 @@ jobs:
503503
504504
- name: Install activerecord and testsuite from PyPI
505505
run: |
506-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
507-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
506+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
507+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
508508
509509
- name: Create test database
510510
run: |
@@ -592,8 +592,8 @@ jobs:
592592
593593
- name: Install activerecord and testsuite from PyPI
594594
run: |
595-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
596-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
595+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
596+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
597597
598598
- name: Create test database
599599
run: |
@@ -681,8 +681,8 @@ jobs:
681681
682682
- name: Install activerecord and testsuite from PyPI
683683
run: |
684-
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev26#egg=rhosocial-activerecord
685-
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev13#egg=rhosocial-activerecord-testsuite
684+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev27#egg=rhosocial-activerecord
685+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev14#egg=rhosocial-activerecord-testsuite
686686
687687
- name: Create test database
688688
run: |

src/rhosocial/activerecord/backend/impl/sqlserver/dialect.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,19 @@ class SQLServerDialect(
246246
"json_array": (SQL_SERVER_2022, None),
247247
}
248248

249-
def __init__(self, version: Tuple[int, int, int] = (16, 0, 0)):
249+
def __init__(self, version: Optional[Tuple[int, int, int]] = None):
250250
"""
251251
Initialize SQL Server dialect with specific version.
252-
252+
253253
Args:
254-
version: SQL Server version tuple (major, minor, patch)
254+
version: SQL Server version tuple (major, minor, patch).
255+
If None, the dialect must be adapted via
256+
backend.introspect_and_adapt() before version-dependent
257+
features can be used.
255258
"""
256-
self.version = version
257259
super().__init__()
260+
if version is not None:
261+
self.version = version
258262

259263
def get_parameter_placeholder(self, position: int = 0) -> str:
260264
"""SQL Server uses ? for placeholders (ODBC/qmark style)."""
@@ -292,10 +296,30 @@ def supports_materialized_cte(self) -> bool:
292296
"""SQL Server doesn't support MATERIALIZED hint for CTEs."""
293297
return False
294298

295-
def supports_returning_clause(self) -> bool:
296-
"""SQL Server supports OUTPUT clause (similar to RETURNING)."""
299+
def supports_returning_insert(self) -> bool:
300+
"""SQL Server supports OUTPUT clause for INSERT."""
297301
return True
298-
302+
303+
def supports_returning_update(self) -> bool:
304+
"""SQL Server supports OUTPUT clause for UPDATE."""
305+
return True
306+
307+
def supports_returning_delete(self) -> bool:
308+
"""SQL Server supports OUTPUT clause for DELETE."""
309+
return True
310+
311+
def supports_constraint_enforced(self) -> bool:
312+
"""SQL Server does not support ENFORCED/NOT ENFORCED constraint control."""
313+
return False
314+
315+
def supports_fk_match(self) -> bool:
316+
"""SQL Server does not support MATCH {SIMPLE|PARTIAL|FULL}."""
317+
return False
318+
319+
def supports_deferrable_constraint(self) -> bool:
320+
"""SQL Server does not support DEFERRABLE constraints."""
321+
return False
322+
299323
def supports_window_functions(self) -> bool:
300324
"""Window functions are supported since SQL Server 2005."""
301325
return True
@@ -1050,7 +1074,7 @@ def _format_column_definition(self, col_def: "ColumnDefinition", ColumnConstrain
10501074
constraint_parts.append(f"DEFAULT {default_sql}")
10511075
params.extend(default_params)
10521076
elif isinstance(constraint.default_value, str):
1053-
escaped = constraint.default_value.replace("'", "''")
1077+
escaped = self._escape_sql_string(constraint.default_value)
10541078
constraint_parts.append(f"DEFAULT '{escaped}'")
10551079
else:
10561080
constraint_parts.append(f"DEFAULT {constraint.default_value}")

0 commit comments

Comments
 (0)