Skip to content

Add MSSQL support behind a new dialect/backend seam and the mssql extra - #14

Merged
aersam merged 4 commits into
mainfrom
worktree-mssql-backend
Jul 25, 2026
Merged

Add MSSQL support behind a new dialect/backend seam and the mssql extra#14
aersam merged 4 commits into
mainfrom
worktree-mssql-backend

Conversation

@aersam

@aersam aersam commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

No description provided.

aersam and others added 4 commits July 25, 2026 08:58
Introduces a thin Dialect wrapper around sqlglot's dialect names (Postgres
stays the unconditional default everywhere), a Backend protocol for
introspection, and a parallel mssql-python-based CRUD/introspection/testdb
implementation. Fixes a pre-existing parser bug along the way: sqlglot
represents explicit "NULL" and "NOT NULL" as the same node type, and the
column parser wasn't checking which, so explicit-NULL columns were wrongly
marked non-nullable for both dialects.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLWLqcTyNJ1ncZvJ5rn6Xy
Minor bump for the new mssql dialect/backend support and the mssql extra.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLWLqcTyNJ1ncZvJ5rn6Xy
- Dependency ordering: T-SQL idempotency guards conventionally reference
  sys.schemas/sys.tables ("IF NOT EXISTS (SELECT ... FROM sys...) BEGIN
  CREATE ... END", since T-SQL has no native "CREATE ... IF NOT EXISTS").
  _get_sql_deps treated those as real cross-file dependencies that never
  resolve, shuffling affected files into the delayed-retry path, whose
  reverse-order resolution then applied a table file before the schema.sql
  file it actually depended on. Exclude sys/pg_catalog/information_schema
  references from dependency tracking for both dialects.
- tests/test_compare_mssql_live.py and tests/db/test_mssql_crud_live.py
  referenced the project_factory fixture, which lives in
  tests/testdb/conftest.py and is only injected into tests under
  tests/testdb/ -- pytest never found it for files outside that directory.
  Call the underlying _make_project helper directly instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLWLqcTyNJ1ncZvJ5rn6Xy
- View/function introspection: sys.sql_modules.definition returns the
  verbatim CREATE [OR ALTER] VIEW/FUNCTION/PROCEDURE statement text, unlike
  Postgres's pg_get_viewdef()/prosrc, which return only the query/body.
  Storing it as-is produced a spurious "definition differs" diff against
  every script-defined view (and would have for functions/procedures too,
  once a project has one). Views: parse the catalog text and re-extract
  just the query, mirroring parser.py's script-side extraction. Functions/
  procedures: reuse parser.py's own _parse_function_details_tsql on the
  catalog text directly, rather than a separate sys.parameters-based path
  that could drift out of sync with it.
- tests/db/test_mssql_crud_live.py's test was `async def`, so pytest-asyncio
  already runs it inside an event loop; ensure_testdb/clean_testdb are sync
  wrappers that call asyncio.run() internally, which raises "cannot be
  called from a running event loop" when nested like that. Made the test
  sync, with a separate asyncio.run() for just the async CRUD calls.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLWLqcTyNJ1ncZvJ5rn6Xy
@aersam
aersam merged commit 7d64d7d into main Jul 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant