Add MSSQL support behind a new dialect/backend seam and the mssql extra - #14
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.