Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions SqlScriptDom/Parser/TSql/TSql170.g
Original file line number Diff line number Diff line change
Expand Up @@ -32520,33 +32520,36 @@ jsonKeyValueExpression returns [JsonKeyValue vResult = FragmentFactory.CreateFra
{
ScalarExpression vKey;
ScalarExpression vValue;
MultiPartIdentifier vMultiPartIdentifier = null;
}
:
(
vKey=expression
{
vResult.JsonKeyName=vKey;
}
Colon vValue=expression
{
vResult.JsonValue=vValue;
}

|

label:Label
(vMultiPartIdentifier=multiPartIdentifier[2] Dot)? label:Label
{
var identifier = this.FragmentFactory.CreateFragment<Identifier>();
var multiPartIdentifier = this.FragmentFactory.CreateFragment<MultiPartIdentifier>();
if (vMultiPartIdentifier == null)
{
vMultiPartIdentifier = this.FragmentFactory.CreateFragment<MultiPartIdentifier>();
}
var columnRef = this.FragmentFactory.CreateFragment<ColumnReferenceExpression>();
CreateIdentifierFromLabel(label, identifier, multiPartIdentifier);
columnRef.MultiPartIdentifier = multiPartIdentifier;
CreateIdentifierFromLabel(label, identifier, vMultiPartIdentifier);

columnRef.MultiPartIdentifier = vMultiPartIdentifier;
vResult.JsonKeyName=columnRef;
}
vValue=expression
{
vResult.JsonValue=vValue;
}
|
vKey=expression
{
vResult.JsonKeyName=vKey;
}
Colon vValue=expression
{
vResult.JsonValue=vValue;
}
)
;

Expand Down
8 changes: 7 additions & 1 deletion Test/SqlDom/Baselines170/JsonFunctionTests170.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,10 @@ GO
CREATE VIEW dbo.jsonfunctest
AS
SELECT JSON_OBJECTAGG(c1:c2) AS jsoncontents
FROM (VALUES ('key1', 'c'), ('key2', 'b'), ('key3', 'a')) AS t(c1, c2);
FROM (VALUES ('key1', 'c'), ('key2', 'b'), ('key3', 'a')) AS t(c1, c2);

GO
SELECT TOP (5) c.object_id,
JSON_OBJECTAGG(c.name:c.column_id) AS columns
FROM sys.columns AS c
GROUP BY c.object_id;
4 changes: 3 additions & 1 deletion Test/SqlDom/Only170SyntaxTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Microsoft.SqlServer.TransactSql.ScriptDom;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SqlStudio.Tests.AssemblyTools.TestCategory;
using System;
using System.Collections.Generic;
using System.IO;

namespace SqlStudio.Tests.UTSqlScriptDom
{
Expand All @@ -17,7 +19,7 @@ public partial class SqlDomTests
new ParserTest170("CreateColumnStoreIndexTests170.sql", nErrors80: 3, nErrors90: 3, nErrors100: 3, nErrors110: 3, nErrors120: 3, nErrors130: 0, nErrors140: 0, nErrors150: 0, nErrors160: 0),
new ParserTest170("RegexpTests170.sql", nErrors80: 0, nErrors90: 0, nErrors100: 0, nErrors110: 0, nErrors120: 0, nErrors130: 0, nErrors140: 0, nErrors150: 0, nErrors160: 0),
new ParserTest170("AiGenerateChunksTests170.sql", nErrors80: 19, nErrors90: 16, nErrors100: 15, nErrors110: 15, nErrors120: 15, nErrors130: 15, nErrors140: 15, nErrors150: 15, nErrors160: 15),
new ParserTest170("JsonFunctionTests170.sql", nErrors80: 10, nErrors90: 8, nErrors100: 35, nErrors110: 35, nErrors120: 35, nErrors130: 35, nErrors140: 35, nErrors150: 35, nErrors160: 35),
new ParserTest170("JsonFunctionTests170.sql", nErrors80: 11, nErrors90: 8, nErrors100: 36, nErrors110: 36, nErrors120: 36, nErrors130: 36, nErrors140: 36, nErrors150: 36, nErrors160: 36),
new ParserTest170("AiGenerateEmbeddingsTests170.sql", nErrors80: 12, nErrors90: 9, nErrors100: 9, nErrors110: 9, nErrors120: 9, nErrors130: 9, nErrors140: 9, nErrors150: 9, nErrors160: 9),
new ParserTest170("CreateExternalModelStatementTests170.sql", nErrors80: 2, nErrors90: 2, nErrors100: 2, nErrors110: 2, nErrors120: 2, nErrors130: 4, nErrors140: 4, nErrors150: 4, nErrors160: 4),
new ParserTest170("AlterExternalModelStatementTests170.sql", nErrors80: 2, nErrors90: 2, nErrors100: 2, nErrors110: 2, nErrors120: 2, nErrors130: 5, nErrors140: 5, nErrors150: 5, nErrors160: 5),
Expand Down
7 changes: 6 additions & 1 deletion Test/SqlDom/TestScripts/JsonFunctionTests170.sql
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@ CREATE VIEW dbo.jsonfunctest AS
SELECT JSON_OBJECTAGG( c1:c2 ) as jsoncontents
FROM (
VALUES('key1', 'c'), ('key2', 'b'), ('key3','a')
) AS t(c1, c2);
) AS t(c1, c2);

GO
SELECT TOP(5) c.object_id, JSON_OBJECTAGG(c.name:c.column_id) AS columns
FROM sys.columns AS c
GROUP BY c.object_id;
Loading