Skip to content

Commit aa13f7e

Browse files
authored
Sync Repos: porting commits for release 161.9123.0 (#86)
* Merged PR 1367589: handle json data type while parsing Json data type has been added to SqlDataTypeOption. However, Json data type is not mapped to this enum while parsing t-sql scripts. For example, for script Create Table t1(c1 json), type of column c1 will be mapped as a UserDefinedType. This PR fixed this issue by adding a ParseDataType160 method in TSql160ParserBaseInternal.cs and map token "json" to SqlDataTypeOption.Json. A test case is added in CreateTableTests160.sql to cover this. ---- #### AI description (iteration 1) #### PR Classification This pull request introduces a new feature to handle JSON data type while parsing in the SQL script. #### PR Summary The changes in this pull request allow the SQL parser to recognize and handle JSON data types. This enhancement improves the versatility of the parser and expands its compatibility with different data types. - In `TSql160ParserBaseInternal.cs`, a new method `ParseDataType160` was added to handle the parsing of JSON data type. - In `TSql160.g`, the method call was updated from `ParseDataType100` to `ParseDataType160` to utilize the new JSON parsing functionality. - Test scripts in `CreateTableTests160.sql` and `TestScripts/CreateTableTests160.sql` were updated to include tests for tables with JSON columns, ensuring the new feature works as expected. Related work items: #3264300 * Merged PR 1381485: Adding release notes for release 9123 Adding release notes for release 9123 ---- #### AI description (iteration 1) #### PR Classification This pull request is primarily for documentation, providing release notes for the new release 9123 of Microsoft.SqlServer.TransactSql.ScriptDom. #### PR Summary The pull request adds a new markdown file for the release notes of version 161.9123.0 of Microsoft.SqlServer.TransactSql.ScriptDom. The notes detail the target platform support, dependencies, fixes, and changes in this release. - Added a new file `/release-notes/161.91/161.9123.0.md` detailing the release notes for version 161.9123.0, including the support for .NET Framework 4.6.2, .NET 6, and .NET Standard 2.0+, as well as a fix for parsing JSON column type in a table. ---------
1 parent e92c8c7 commit aa13f7e

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

SqlScriptDom/Parser/TSql/TSql160.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30081,7 +30081,7 @@ scalarDataType returns [DataTypeReference vResult = null]
3008130081
if (vName.SchemaIdentifier == null ||
3008230082
(vName.SchemaIdentifier != null && IsSys(vName.SchemaIdentifier)))
3008330083
{
30084-
typeOption = ParseDataType100(vName.BaseIdentifier.Value);
30084+
typeOption = ParseDataType160(vName.BaseIdentifier.Value);
3008530085
isXmlDataType = IsXml(vName.BaseIdentifier);
3008630086
}
3008730087
}

SqlScriptDom/Parser/TSql/TSql160ParserBaseInternal.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ protected static void VerifyAllowedIndexOption160(IndexAffectingStatement statem
5656
VerifyAllowedOnlineIndexOptionLowPriorityLockWait(statement, option);
5757
}
5858

59+
protected static SqlDataTypeOption ParseDataType160(string token)
60+
{
61+
switch (token.ToUpperInvariant())
62+
{
63+
case "JSON":
64+
return SqlDataTypeOption.Json;
65+
default:
66+
return ParseDataType100(token);
67+
}
68+
}
69+
5970
/// <summary>
6071
/// Checks if table definition contains 'generated always' columns that match period definition,
6172
/// if period definition exists.

Test/SqlDom/Baselines160/CreateTableTests160.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
CREATE TABLE t1 (
2+
c1 JSON
3+
);
4+
15
CREATE TABLE t1 (
26
c1 INT
37
)

Test/SqlDom/TestScripts/CreateTableTests160.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
-- Table with Json Column
2+
CREATE TABLE t1(c1 json)
3+
14
-- xml compression
25
CREATE TABLE t1 (c1 INT)
36
WITH (XML_COMPRESSION = ON ON PARTITIONS (1))

release-notes/161.91/161.9123.0.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Release Notes
2+
3+
## Microsoft.SqlServer.TransactSql.ScriptDom 161.9123.0
4+
This update brings the below changes over the previous release:
5+
6+
### Target Platform Support
7+
8+
* .NET Framework 4.6.2 (Windows x86, Windows x64)
9+
* .NET 6 (Windows x86, Windows x64, Linux, macOS)
10+
* .NET Standard 2.0+ (Windows x86, Windows x64, Linux, macOS)
11+
12+
### Dependencies
13+
14+
#### .NET Framework
15+
#### .NET Core
16+
#### .NET Standard
17+
18+
### Fixed
19+
* Fixes parsing of scripts with JSON type.
20+
21+
### Changes
22+
23+
### Known Issues

0 commit comments

Comments
 (0)