Commit d7442e4
committed
BACPAC loader — long tail: ISJSON + DECOMPRESS + scalar-UDF
**`IsJson` expression** (`SqlServerSimulator/Parser/Expressions/IsJson.cs`). Wraps `System.Text.Json.JsonDocument.Parse` in try/catch; returns int 1 on parse success, 0 on JsonException, NULL on NULL input, 0 on non-string input. Dispatched from `Expression.cs`'s length-6 switch (`"ISJSON" => new IsJson(context)`). 2-arg shape (with `VALUE | ARRAY | OBJECT | SCALAR` modifier) intentionally not modeled — DACFx-emitted CHECK constraints use the 1-arg form. Unblocks WWI's `CK_Sales_Invoices_ReturnedDeliveryData_Must_Be_Valid_JSON` CHECK constraint.
**`Decompress` expression** (`SqlServerSimulator/Parser/Expressions/Decompress.cs`). `System.IO.Compression.GZipStream.CopyTo` on a varbinary argument; returns the inflated bytes as varbinary. NULL input → NULL. Invalid gzip stream returns NULL pending a proper Msg 9803 factory (DACFx-emitted views invoke DECOMPRESS only on known-compressed columns, so the wording doesn't matter for the loader baseline). Dispatched from the length-10 switch. Unblocks WWI's `Website.VehicleTemperatures` view (which casts DECOMPRESS output to nvarchar(1000)).
**Scalar-UDF `ParseScalarTail` extended WITH options** (`SqlServerSimulator/Simulation/Simulation.CreateFunction.cs`). The old code accepted only `WITH RETURNS NULL ON NULL INPUT` and hard-rejected everything else. Rewrote into a comma-separated multi-option loop accepting `RETURNS NULL ON NULL INPUT` / `SCHEMABINDING` / `ENCRYPTION` / `EXECUTE AS CALLER|SELF|OWNER|'name'` — only the first affects runtime semantics (NULL-propagation skips the body); the others parse-and-discard since the simulator has no principal model and no schema-binding-dependency tracking. Unblocks WWI's `Website.CalculateCustomerPrice` (`WITH EXECUTE AS OWNER`) — but the surprise win was AW's `dbo.ufnLeadingZeros` (`WITH SCHEMABINDING`), which had been silently failing CREATE and cascade-blocking every AW computed column that referenced it. Net effect on AW: SqlComputedColumn category clears from Skipped entirely; index count 89 → 93 (the previously-blocked filtered indexes now resolve); funcs 10 → 11.
**`SqlFilegroup` skip dispatch** (`ModelXmlReader.cs`). New phase-1 no-op handler — `("SqlFilegroup", 1) => Run(static () => { })` — and `IsHandledByAnotherPhase` updated. Filegroups are storage-layout metadata; the simulator has a single in-process heap so they're parse-and-discard.
**`SqlIndex` dispatch moves phase 5 → phase 8** (`ModelXmlReader.cs`). Phase 8 also hosts deferred computed columns; element-document-order in WWI / AW puts SqlTable's deferred-computed-column ALTER passes ahead of SqlIndex emissions, so filtered indexes whose predicates reference computed columns now resolve correctly. The phase-comment block is rewritten: phase 5 is now unused (deliberately — keeping the existing 9-phase numbering); phase 8 explicitly carries both SqlTable computed-column ALTERs and SqlIndex emissions. AW reports the gain as +4 indexes; WWI reports the gain as +3 (the `IX_*_IsFinalized` / `IX_*_ConfirmedDeliveryTime` filtered indexes).
**Test updates**:
- `Load_AW_Indexes_Land` — expected count 89 → 93; Skipped expected count 6 → 2; the two remaining are view-targeted (indexed views, SCHEMABINDING-gated).
- `Load_AW_Programmable_Counts` — funcs 10 → 11.
- `Load_AW_Unhandled_Elements_Recorded_In_Skipped` — `IsNotEmpty(SqlComputedColumn)` assertion removed (category cleared); comment rewritten to call out the SCHEMABINDING cascade and the remaining permission-statement gap.
- `Load_WWI_Known_Gaps_Recorded_In_Skipped` — rewritten to assert *absence* of SqlIndex / SqlView / SqlScalarFunction / SqlFilegroup categories (and keep the existing SqlTableType / SqlProcedure / SqlComputedColumn absence assertions). The 1 remaining SqlCheckConstraint and 2 SqlPermissionStatement entries are documented inline.
**Doc updates**: `CLAUDE.md`'s BACPAC pointer refreshes the WWI census to add 94/94 indexes + 3/3 views + 1/1 scalar function. `docs/claude/bacpac-prerequisites.md` gets a new step 7 covering this bundle; step 10's gap inventory drops the resolved categories and documents the 3 remaining (SqlExtendedProperty cascade, SqlPermissionStatement encryption keys, SqlCheckConstraint parser gap on paren-wrapped value subexpressions). Status section's WWI summary picks up the new element counts.WITH SCHEMABINDING / EXECUTE AS + Filegroup skip + index-after-computed reorder. Five small fixes whose combined effect closed most of the remaining WWI gap inventory and cascade-cleared AW's deferred-computed-column gap that I'd thought required a larger parser refactor. WWI gap census drops from 8 categories to 3; AW SqlComputedColumn cascade-clears, lifting AW indexes 89 → 93 and AW scalar UDF count 10 → 11.1 parent 8454339 commit d7442e4
15 files changed
Lines changed: 525 additions & 75 deletions
File tree
- SqlServerSimulator.Tests.Internal/Storage
- SqlServerSimulator.Tests
- SqlServerSimulator
- Parser
- Expressions
- Simulation
- Storage
- Bacpac
- docs/claude
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
Lines changed: 33 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | | - | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| |||
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
202 | 205 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| |||
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
241 | | - | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| |||
598 | 601 | | |
599 | 602 | | |
600 | 603 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
608 | 619 | | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | 620 | | |
613 | 621 | | |
614 | 622 | | |
| |||
0 commit comments