Repository navigation
Conversation
A computed column declares no type, so the converter left it with an empty type name and the whole schema failed to load. The converter now carries the expression as a generated-column constraint, and the core types it against the table's other columns, falling back to an untyped column rather than failing. SQL Server describes most computed columns as nullable, even PERSISTED NOT NULL ones, so the converter marks only the expressions it keeps NOT NULL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CREATE VIEW was ignored, so a query reading a view failed as an unknown relation. CREATE VIEW, CREATE OR ALTER VIEW and ALTER VIEW now convert to the view statement the core already records, with the columns its query selects or its column list names, and DROP VIEW drops it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A computed column took the type its expression was analyzed as, but the analysis reports the family's row for a type with arguments no column has interned, so CAST(price AS nvarchar(37)) was stored as nvarchar and read back as the nvarchar(1) a bare declaration means. A type with arguments is now resolved as the whole expression. Addresses review comment r4557025274 on #1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ALTER COLUMN was ignored, so a column kept the type and nullability it was created with. It now converts to the column type and NOT NULL changes the core already applies: a new type with NOT NULL keeps the column NOT NULL, and one without makes it nullable, as SQL Server does. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SQL Server renames a table or column with EXEC sp_rename, which was ignored as a procedure call, so a schema kept the old names. A call of sp_rename, its arguments by position or by name, now converts to the table or column rename the core already applies. Any other procedure call is still no statement sqlc has a use for. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A migration script guards its changes, as IF OBJECT_ID('t') IS NULL
CREATE TABLE t ... does, and a statement inside an IF or BEGIN ... END
block was skipped with the block, so such a schema was empty. The schema
changes in a block's THEN branch are now applied, each tolerating the
object being there or not, since the guard decides that: a create of
one that exists, and a drop, alter or rename of one that does not, are
skipped. Queries and data changes inside a block are still left out.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CREATE SEQUENCE was ignored, so NEXT VALUE FOR could not be typed and the query failed. A sequence is now recorded as a function returning its type, bigint unless AS names another, which NEXT VALUE FOR calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CREATE SYNONYM was ignored, so a query naming a synonym failed. A synonym is now recorded as a view of everything in what it names. A synonym may as well name a procedure, or something not yet created, which leaves nothing to select from it, so it is then left out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ALTER SCHEMA s TRANSFER t, which moves a table or view to schema s, was ignored, leaving t where it was. The core schema now moves a relation for ALTER TABLE ... SET SCHEMA, which PostgreSQL's converter already produces, and SQL Server's TRANSFER converts to it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Schema objects and DDL that SQL Server schemas use, applied to the catalog: views, computed columns (with their length and precision), ALTER TABLE ALTER COLUMN, sp_rename, ALTER SCHEMA … TRANSFER, schema changes inside IF/BEGIN … END blocks, sequences (NEXT VALUE FOR) and synonyms.
Commits
07566c853feat(mssql): type computed columns by their expression6ae8fb1d5feat(mssql): support viewse49d9b22afix(mssql): keep the length and precision of a computed column0995c0a85feat(mssql): apply ALTER TABLE ALTER COLUMN4a2d38bdefeat(mssql): apply sp_rename to tables and columns4bbce3455feat(mssql): apply the schema changes in IF and BEGIN ... END blocksbbda21d2bfeat(mssql): type NEXT VALUE FOR a sequence475e15b20feat(mssql): select from a synonym the schema creates586e335d6feat(mssql): apply ALTER SCHEMA ... TRANSFERTest changes for independence
analyze_computed_columns: the CONCAT and ISNULL computed columns are left out, since those are typed by the expression typing PR's seeds.Independence. This is one of five PRs split from #1, each off
mainwith no dependency on the others: it builds, passes the base suite and keeps the core context at or abovemain's, alone. Its goldens are generated on this branch, and they hold unchanged with all five merged, whose code then equals the original branch. Parallel PRs add lines next to each other inconvert.go,functions.jsonland the dialect settings, so whichever merges later may need a rebase that keeps both sides.Verification. Behavior was checked against SQL Server 2025 in #1 (goldeneye or
sp_describe_*).go test ./internal/endtoend -run TestReplay/base/and the touched packages' tests pass; generated Go goldens passgo vet.