Skip to content

Commit ab77781

Browse files
authored
Sync repos: release 170.147.0 (#185)
* [Security] Update .NET SDK to latest patch version (8.0.415) * Merged PR 1847463: Adding support for option RESUMABLE in ALTER TABLE ADD CONSTRAINT GitHub bug: #125 RESUMABLE is valid for 160+ reference: https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-ver17#resumable---on--off Max_Duration is valid for 120+ Reference: https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-ver17#max_duration--time--minutes- This PR introduces version-gated logic to allow RESUMABLE (and MAX_DURATION) only when the SQL Server version supports it, and updates related tests and documentation to clearly guide such validation fixes. - Updated `/SqlScriptDom/Parser/TSql/TSql80ParserBaseInternal.cs` to replace unconditional option rejections with checks using version flags (TSql160AndAbove and TSql120AndAbove). - Added new test scripts and baselines in `/Test/SqlDom/TestScripts/AlterTableResumableTests160.sql` and `/Test/SqlDom/Baselines160/AlterTableResumableTests160.sql`, and updated `/Test/SqlDom/Only160SyntaxTests.cs` to verify version-specific error counts. - Added comprehensive documentation in new files (e.g., `/.github/VALIDATION_FIX_GUIDE.md`, `/.github/DEBUGGING_WORKFLOW.md`, and `/.github/README.md`) to assist users in handling validation issues like this. - Updated copilot and bug fixing guides (in `/.github/copilot-instructions.md` and `/.github/BUG_FIXING_GUIDE.md`) with decision trees and pract... * Merged PR 1870990: Fixing the bug JSON_OBJECT does not parse inside RETURN statement # Pull Request Template for ScriptDom ## Description Fixing bug #181 Fixing the bug JSON_OBJECT does not parse inside RETURN statement Bug fix and documentation update to ensure JSON_OBJECT (and related JSON functions) parse correctly inside RETURN statements. #### PR Summary This pull request fixes the issue where JSON_OBJECT was failing in RETURN statements by introducing token-based syntactic predicates across multiple grammar files, and it also adds supporting test cases and comprehensive documentation updates for testing and function extension in SqlScriptDOM. - `SqlScriptDom/Parser/TSql/TSql160.g`, `TSql170.g`, and `TSqlFabricDW.g`: Added new `jsonObjectCall` and `jsonArrayCall` rules with proper syntactic predicates. - `Test/SqlDom/TestScripts` and `Test/SqlDom/Baselines160`: Introduced new tests and baselines for JSON_OBJECT, JSON_ARRAY, and TRIM usage in RETURN statements. - `/.github/instructions` and `/.github/prompts`: Added detailed guidelines for testing, new system function implementation, and grammar extension patterns. - `Test/SqlDom/Only160SyntaxTests.cs` and `/.github/copilot-instructions.md`: Updated test configurations and documentation references to include the new JSON function tests. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> * Merged PR 1874197: Adding prompts to help developer using github copilot # Pull Request Template for ScriptDom ## Description - Adding prompt files to run in VScode github copilot and it help developers with using the copilot to generate the code. - Adding more instructions files for new features - Fixing the test library to write enough info for copilot to know better how to fix the tests. #### PR Summary This PR adds detailed guidelines for adding new index and data types, a new feature implementation prompt to assist GitHub Copilot users, and updates testing and documentation instructions throughout the repository. - Added new guideline files: `/.github/instructions/new_index_types.guidelines.instructions.md` and `/.github/instructions/new_data_types.guidelines.instructions.md` with step‑by‑step instructions. - Introduced a new prompt file `/.github/prompts/new-feature-implementation.prompt.md` to guide feature type identification for developers. - Updated testing guidance in `/.github/instructions/testing.guidelines.instructions.md` and refactored ParserTest constructors to use nullable error counts. - Modified copilot instructions and README links to reflect renamed and relocated guidelines. - Made minor changes in test utilities and baseline test files to support these updates. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> * Merged PR 1870962: Add test case for JSON_OBJECTAGG with qualified column references (GitHub issue #175) ## Issue Users reported that `JSON_OBJECTAGG` was not parsing correctly with TSql170Parser, receiving the error &quot;Incorrect syntax near &#39;:&#39;&quot;. Example that was failing: ```sql SELECT JSON_OBJECTAGG( t.c1 : t.c2 ) FROM ( VALUES(&#39;key1&#39;, &#39;c&#39;), (&#39;key2&#39;, &#39;b&#39;), (&#39;key3&#39;,&#39;a&#39;) ) AS t(c1, c2); ``` ## Investigation Results After thorough analysis, I found that **the grammar for JSON_OBJECTAGG is already complete and correct** in `SqlScriptDom/Parser/TSql/TSql170.g`. All supporting code exists: - ✅ Grammar rules in TSql170.g (lines 32584, 33029-30, 33135) - ✅ `jsonKeyValueExpression` rule handles both shorthand and explicit colon syntax - ✅ `CodeGenerationSupporter.JsonObjectAgg` constant defined - ✅ `JsonKeyValue` AST class with proper properties - ✅ Script generator visitor for JsonKeyValue - ✅ Comprehensive positive tests in `JsonFunctionTests170.sql` - ✅ Comprehensive negative tests in `ParserErrorsTests.cs` ## Root Cause The issue is that the **parser needs to be regenerated** from the grammar files via the build process. The grammar has the correct implementation, but the generated parser code needs to be updated. ## Changes Made Added a test case to `JsonFunctionTests170.sql` that exactly matches the reported issue scenario: - **Test script**: Added test with qualified column names `t.c1 : t.c2` - **Baseline**: Added expected normalized output This ensures future builds will include this specific test case and the parser will handle qualified column references in JSON_OBJECTAGG correctly. ## Next Steps When the build runs, it will: 1. Regenerate the parser from TSql170.g using ANTLR 2. Compile the updated parser 3. Run all tests (which should pass) 4. Publish a new NuGet package with the working parser ## Verification The fix can be verified with: ```csharp var script = @&quot;SELECT JSON_OBJECTAGG( t.c1 : t.c2 ) FROM ( VALUES(&#39;key1&#39;, &#39;c&#39;), (&#39;key2&#39;, &#39;b&#39;), (&#39;key3&#39;,&#39;a&#39;) ) AS t(c1, c2);&quot;; var parser = new TSql170Parser(true); var fragment = parser.Parse(new StringReader(script), out var parseErrors); Assert.AreEqual(0, parseErrors.Count); // Should pass after build ``` Fixes: [scriptdom is missing json_objectagg](https://msdata.visualstudio.com/web/wi.aspx?pcguid=8b119ea1-2e2a-4839-8db7-8c9e8d50f6fa&amp;id=4792111) <p><small class=\"secondary-text\">AI-generated content may be incorrect</small></p> <!-- GitOpsUserAgent=GitOps.Apps.Server.copilotswe --> Co-authored-by: Azure Pipelines Test Service <> Co-authored-by: GitHub Copilot <> Co-authored-by: Leila Lali <[email protected]> Related work items: #4792111 * Merged PR 1882663: Adding a prompt to analyze dsmain ADO commit # Pull Request Template for ScriptDom This PR introduces new automation prompts and demo instructions for ADO commit analysis and T-SQL verification, along with updates to testing guidelines and configuration adjustments. #### PR Summary The changes add detailed prompts and demonstration files to automate the analysis of ADO commits (including VECTOR_SEARCH validation and bug reporting), update testing instructions and guidelines to enforce unit test best practices, and adjust ADO configuration settings. - **`.github/prompts/analyze-ado-commit-for-tsql-verification.prompt.md`**: New prompt outlining the complete workflow for analyzing ADO commits for T-SQL verification and creating bug reports. - **`.github/demo/analyze_ado_commit_demo.md` & `.github/demo/new-feature-implementation_demo.md`**: Demo files showcasing the automated analysis process and the implementation fix for the VECTOR_SEARCH function (supporting 3-part identifiers). - **`.github/prompts/verify-and-test-tsql-syntax.prompt.md`**: Updated prompt with enhanced debugging and unit test instructions for verifying T-SQL syntax. - **Guideline Instruction Updates (`.github/instructions/*`)**: Revised testing, bug fixing, and function guidelines to mandate unit test usage and align testing procedures. - **`.vscode/mcp.json`**: Modified ADO configuration with an updated area path for proper integration. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> * remove some ADO guidlines * Merged PR 1898573: Adding Release notes for 170.147.0 Adding Release notes for 170.147.0
1 parent f09e0b8 commit ab77781

40 files changed

+4742
-86
lines changed

.github/README.md

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
# SqlScriptDOM Documentation Guide
2+
3+
Welcome to the SqlScriptDOM documentation! This folder contains comprehensive guides for understanding, developing, and debugging the SQL Server T-SQL parser.
4+
5+
## 🚀 Quick Start
6+
7+
**New to the project?** Start here:
8+
1. Read [copilot-instructions.md](copilot-instructions.md) - Main project documentation
9+
2. Browse [debugging_workflow.guidelines.instructions.md](instructions/debugging_workflow.guidelines.instructions.md) - Visual quick reference
10+
11+
**Fixing a bug?** Start here:
12+
1. Open [debugging_workflow.guidelines.instructions.md](instructions/debugging_workflow.guidelines.instructions.md) - Identify bug type
13+
2. Follow the flowchart to the appropriate guide
14+
3. Use the step-by-step instructions
15+
16+
## 📚 Documentation Map
17+
18+
### Core Documentation
19+
20+
#### [copilot-instructions.md](copilot-instructions.md) - **START HERE**
21+
**Purpose**: Main project documentation and overview
22+
**Contains**:
23+
- Project structure and key files
24+
- Build and test commands
25+
- Developer workflow
26+
- Bug fixing triage
27+
- Debugging tips
28+
- Grammar gotchas and pitfalls
29+
30+
**When to read**: First time working on the project, or for general context
31+
32+
---
33+
34+
### Quick Reference
35+
36+
#### [debugging_workflow.guidelines.instructions.md](instructions/debugging_workflow.guidelines.instructions.md) - **QUICK REFERENCE**
37+
**Purpose**: Visual guide for quick bug diagnosis
38+
**Contains**:
39+
- Diagnostic flowchart
40+
- Error pattern recognition
41+
- Investigation steps
42+
- Testing commands reference
43+
- Key files reference
44+
- Common pitfalls
45+
46+
**When to use**: When you have a bug and need to quickly identify what type of fix is needed
47+
48+
---
49+
50+
### Specialized Fix Guides
51+
52+
#### [Validation_fix.guidelines.instructions.md](instructions/Validation_fix.guidelines.instructions.md) - Most Common Fix Type ⭐
53+
**Purpose**: Fixing validation-based bugs
54+
**When to use**:
55+
- ✅ Error: "Option 'X' is not valid..." or "Feature not supported..."
56+
- ✅ Same syntax works in different context (e.g., ALTER INDEX vs ALTER TABLE)
57+
- ✅ SQL Server version-specific features
58+
59+
**Contains**:
60+
- Real-world example (ALTER TABLE ADD CONSTRAINT RESUMABLE)
61+
- Version flag patterns
62+
- Validation logic modification
63+
- Testing strategy
64+
65+
**Complexity**: ⭐ Easy
66+
**Typical time**: 1-2 hours
67+
68+
---
69+
70+
#### [bug_fixing.guidelines.instructions.md](instructions/bug_fixing.guidelines.instructions.md) - Grammar Changes
71+
**Purpose**: Adding new syntax or modifying parser grammar
72+
**When to use**:
73+
- ✅ Error: "Incorrect syntax near..." or "Unexpected token..."
74+
- ✅ Parser doesn't recognize new T-SQL features
75+
- ✅ Need to add new keywords, operators, or statements
76+
77+
**Contains**:
78+
- Complete bug-fixing workflow
79+
- Grammar modification process
80+
- AST updates
81+
- Script generator changes
82+
- Baseline generation
83+
- Decision tree for bug types
84+
85+
**Complexity**: ⭐⭐⭐ Medium to Hard
86+
**Typical time**: 4-8 hours
87+
88+
---
89+
90+
#### [parser.guidelines.instructions.md](instructions/parser.guidelines.instructions.md)
91+
**Purpose**: Fixing parentheses recognition issues
92+
**When to use**:
93+
-`WHERE PREDICATE(...)` works
94+
-`WHERE (PREDICATE(...))` fails with syntax error
95+
- ✅ Identifier-based boolean predicates
96+
97+
**Contains**:
98+
- `IsNextRuleBooleanParenthesis()` modification
99+
- Predicate detection patterns
100+
- Real example (REGEXP_LIKE)
101+
102+
**Complexity**: ⭐⭐ Easy-Medium
103+
**Typical time**: 1-3 hours
104+
105+
---
106+
107+
#### [grammer.guidelines.instructions.md](instructions/grammer.guidelines.instructions.md)
108+
**Purpose**: Common patterns for extending existing grammar
109+
**When to use**:
110+
- ✅ Need to extend literal types to accept expressions
111+
- ✅ Adding new enum members
112+
- ✅ Creating new function/statement types
113+
114+
**Contains**:
115+
- Literal to expression pattern
116+
- Real example (VECTOR_SEARCH TOP_N)
117+
- Context-specific grammar rules
118+
- Shared rule warnings
119+
120+
**Complexity**: ⭐⭐⭐ Medium
121+
**Typical time**: 3-6 hours
122+
123+
---
124+
125+
### Meta Documentation
126+
127+
#### [documentation.guidelines.instructions.md](instructions/documentation.guidelines.instructions.md)
128+
**Purpose**: Summary of documentation improvements
129+
**Contains**:
130+
- What was improved and why
131+
- Before/after comparison
132+
- Real-world validation (ALTER TABLE RESUMABLE)
133+
- Lessons learned
134+
135+
**When to read**: If you want to understand the documentation structure and evolution
136+
137+
---
138+
139+
## 🎯 Bug Type Decision Tree
140+
141+
```
142+
┌─────────────────────────────────┐
143+
│ You have a parsing bug │
144+
└───────────┬─────────────────────┘
145+
146+
147+
┌───────────────┐
148+
│ What's the │
149+
│ error message?│
150+
└───────┬───────┘
151+
152+
┌────────┼────────┐
153+
│ │ │
154+
▼ ▼ ▼
155+
┌──────┐ ┌──────┐ ┌──────┐
156+
│Option│ │Syntax│ │Parens│
157+
│error │ │error │ │break │
158+
└──┬───┘ └──┬───┘ └──┬───┘
159+
│ │ │
160+
▼ ▼ ▼
161+
┌──────┐ ┌──────┐ ┌──────┐
162+
│VALID-│ │BUG │ │PARSER│
163+
│ATION │ │FIXING│ │PRED │
164+
│FIX │ │GUIDE │ │RECOG │
165+
└──────┘ └──────┘ └──────┘
166+
```
167+
168+
## 📋 Quick Reference Table
169+
170+
| Error Message | Bug Type | Guide | Complexity |
171+
|--------------|----------|-------|------------|
172+
| "Option 'X' is not valid in statement Y" | Validation | [Validation_fix.guidelines.instructions.md](instructions/Validation_fix.guidelines.instructions.md) | ⭐ Easy |
173+
| "Feature 'X' not supported in version Y" | Validation | [Validation_fix.guidelines.instructions.md](instructions/Validation_fix.guidelines.instructions.md) | ⭐ Easy |
174+
| "Incorrect syntax near keyword" | Grammar | [bug_fixing.guidelines.instructions.md](instructions/bug_fixing.guidelines.instructions.md) | ⭐⭐⭐ Medium |
175+
| "Unexpected token" | Grammar | [bug_fixing.guidelines.instructions.md](instructions/bug_fixing.guidelines.instructions.md) | ⭐⭐⭐ Medium |
176+
| Syntax error with parentheses only | Predicate Recognition | [parser.guidelines.instructions.md](instructions/parser.guidelines.instructions.md) | ⭐⭐ Easy-Medium |
177+
| Need to extend literal to expression | Grammar Extension | [GRAMMAR_EXTENSION_PATTERNS](GRAMMAR_EXTENSION_PATTERNS.md) | ⭐⭐⭐ Medium |
178+
179+
## 🔍 Common Scenarios
180+
181+
### Scenario 1: New SQL Server Feature Not Recognized
182+
**Example**: `ALTER TABLE ... WITH (RESUMABLE = ON)` fails
183+
**Likely Issue**: Validation blocking the option
184+
**Start With**: [VALIDATION_FIX_GUIDE.md](VALIDATION_FIX_GUIDE.md)
185+
186+
### Scenario 2: New T-SQL Keyword Not Parsed
187+
**Example**: `CREATE EXTERNAL TABLE` not recognized
188+
**Likely Issue**: Grammar doesn't have rules for this syntax
189+
**Start With**: [BUG_FIXING_GUIDE.md](BUG_FIXING_GUIDE.md)
190+
191+
### Scenario 3: Function Works Sometimes, Fails with Parentheses
192+
**Example**: `WHERE REGEXP_LIKE(...)` fails
193+
**Likely Issue**: Predicate recognition
194+
**Start With**: [PARSER_PREDICATE_RECOGNITION_FIX.md](PARSER_PREDICATE_RECOGNITION_FIX.md)
195+
196+
### Scenario 4: Parameter Support Needed
197+
**Example**: `TOP_N = @parameter` should work
198+
**Likely Issue**: Need to extend from literal to expression
199+
**Start With**: [GRAMMAR_EXTENSION_PATTERNS.md](GRAMMAR_EXTENSION_PATTERNS.md)
200+
201+
## 🛠️ Essential Commands
202+
203+
```bash
204+
# Build parser
205+
dotnet build SqlScriptDom/Microsoft.SqlServer.TransactSql.ScriptDom.csproj -c Debug
206+
207+
# Run specific test
208+
dotnet test --filter "FullyQualifiedName~YourTest" -c Debug
209+
210+
# Run ALL tests (CRITICAL before committing!)
211+
dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug
212+
213+
# Search for error code
214+
grep -r "SQL46057" SqlScriptDom/
215+
216+
# Search for option usage
217+
grep -r "RESUMABLE" Test/SqlDom/TestScripts/
218+
```
219+
220+
## 📊 Documentation Statistics
221+
222+
- **Total Guides**: 6 comprehensive guides
223+
- **Bug Types Covered**: 3 main types (validation, grammar, predicate recognition)
224+
- **Real-World Examples**: 4 detailed examples with code
225+
- **Code Samples**: 50+ practical bash/C#/SQL examples
226+
- **Quick References**: 3 tables and 2 flowcharts
227+
228+
## 🎓 Learning Path
229+
230+
### Beginner Path (Understanding the Project)
231+
1. [copilot-instructions.md](copilot-instructions.md) - Read "Key points" section
232+
2. [debugging_workflow.guidelines.instructions.md](instructions/debugging_workflow.guidelines.instructions.md) - Understand bug types
233+
3. [Validation_fix.guidelines.instructions.md](instructions/Validation_fix.guidelines.instructions.md) - Follow ALTER TABLE RESUMABLE example
234+
4. Try fixing a validation bug yourself
235+
236+
**Time**: 2-3 hours
237+
238+
### Intermediate Path (Grammar Changes)
239+
1. Review beginner path first
240+
2. [bug_fixing.guidelines.instructions.md](instructions/bug_fixing.guidelines.instructions.md) - Complete workflow
241+
3. [grammer.guidelines.instructions.md](instructions/grammer.guidelines.instructions.md) - Common patterns
242+
4. [copilot-instructions.md](copilot-instructions.md) - "Grammar Gotchas" section
243+
5. Try adding a simple new keyword
244+
245+
**Time**: 4-6 hours
246+
247+
### Advanced Path (Complex Features)
248+
1. Master beginner and intermediate paths
249+
2. [bug_fixing.guidelines.instructions.md](instructions/bug_fixing.guidelines.instructions.md) - AST modifications
250+
3. [grammer.guidelines.instructions.md](instructions/grammer.guidelines.instructions.md) - All patterns
251+
4. Study existing complex features (e.g., VECTOR_SEARCH)
252+
5. Implement a new statement type
253+
254+
**Time**: 8-16 hours
255+
256+
## 🚨 Critical Reminders
257+
258+
### Always Do This:
259+
-**Run full test suite** before committing (1,100+ tests)
260+
-**Check Microsoft docs** for exact version support
261+
-**Search for error messages** first before coding
262+
-**Create context-specific rules** instead of modifying shared ones
263+
-**Test across all SQL Server versions** in test configuration
264+
265+
### Never Do This:
266+
- ❌ Modify shared grammar rules without understanding impact
267+
- ❌ Skip running the full test suite
268+
- ❌ Assume version support - always verify documentation
269+
- ❌ Edit generated files in `obj/` directory
270+
- ❌ Commit without testing baseline generation
271+
272+
## 🤝 Contributing
273+
274+
When improving these docs:
275+
1. Use real examples from actual bugs
276+
2. Include complete code samples (not pseudo-code)
277+
3. Add bash commands that actually work
278+
4. Cross-reference related guides
279+
5. Update this README if adding new guides
280+
281+
## 📞 Getting Help
282+
283+
If stuck:
284+
1. Search error message in codebase: `grep -r "your error"`
285+
2. Check similar working syntax: `grep -r "keyword" Test/SqlDom/`
286+
3. Review relevant guide based on bug type
287+
4. Check Git history for similar fixes: `git log --grep="RESUMABLE"`
288+
289+
## 🎉 Success Metrics
290+
291+
You know you've succeeded when:
292+
- ✅ Your specific test passes
293+
-**ALL 1,100+ tests pass** (critical!)
294+
- ✅ Baseline matches generated output
295+
- ✅ Version-specific behavior is correct
296+
- ✅ No regressions in existing functionality
297+
298+
---
299+
300+
**Last Updated**: Based on ALTER TABLE RESUMABLE fix (October 2025)
301+
302+
**Contributors**: Documentation improved based on practical bug-fixing experience
303+
304+
**Feedback**: These guides are living documents. Please update them when you discover new patterns or better approaches!

0 commit comments

Comments
 (0)