Skip to content

Support Northwind schemas; fix the table count introduced in #362 - #363

Open
Wenjie Fan (gggdttt) wants to merge 2 commits into
masterfrom
fix/sqlschema-to-al-quoted-identifiers
Open

Support Northwind schemas; fix the table count introduced in #362#363
Wenjie Fan (gggdttt) wants to merge 2 commits into
masterfrom
fix/sqlschema-to-al-quoted-identifiers

Conversation

@gggdttt

@gggdttt Wenjie Fan (gggdttt) commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #362, after the review question about whether Northwind's schema is supported. It isn't — this adds it. One of the three changes is a regression from #362, the other two are long-standing gaps; noting which is which below.

Regression from #362

The closing line Generated N table definition(s) was added in #362 and counts CREATE TABLE statements the regex matched, not files actually written. Those two numbers differ whenever a table is skipped, so the script can claim success for tables it never produced. It now reports Generated X of Y, and warns when a CREATE TABLE in the file could not be parsed.

This is the change that matters most for anyone scripting a large database in chunks, where a quietly skipped table would only surface much later during migration.

Pre-existing gaps

Neither of these ever worked, before or after #362.

Double-quoted identifiers. Northwind mixes two styles in one file: 8 tables are scripted as CREATE TABLE "Employees" ("EmployeeID" "int" NOT NULL, ...), the other 5 use brackets. On the pre-#362 script the quoted tables produce Unkown column type NULL for every column and then fail on Out-File with MSFT"Employees".Table.al, which is not a legal Windows filename, so the run yields no table files at all. The identifier pattern, the bracket-stripping helper, the key-column regex and the comma splitter now all accept "..." alongside [...].

ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY. SSMS Script Table as > CREATE To puts the primary key inside the CREATE TABLE; Tasks > Generate Scripts emits it as a separate ALTER TABLE afterwards. Only the inline form was recognised, so tables scripted the second way were dropped for having no key. Those statements are now collected up front and used when a table has no inline key.

Testing

Northwind (from microsoft/sql-server-samples): 13 of 13 tables, no warnings, generated AL compiles.

Dynamics GP regression, 5 tables including a composite key: output is field-for-field identical to the pre-#362 script — same field IDs, names, AL types and key columns — and both versions compile.

The suite covers 14 scenarios and compiles every generated extension with alc.exe rather than only inspecting the text.

@gggdttt Wenjie Fan (gggdttt) changed the title Support double-quoted identifiers and ALTER TABLE primary keys in SQLSchema-To-ALExtension.ps1 Support Northwind schemas; fix the table count introduced in #362 Sep 3, 2026
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