@@ -124,13 +124,13 @@ protected override ShapedQueryExpression TranslateCollection(
124
124
{
125
125
var elementClrType = sqlExpression . Type . GetSequenceType ( ) ;
126
126
127
- // Generate the OpenJson function expression, and wrap it in a SelectExpression.
128
- // Note that we want to preserve the ordering of the element's, i.e. for the rows coming out of OpenJson to be the same as the
127
+ // Generate the OPENJSON function expression, and wrap it in a SelectExpression.
128
+ // Note that we want to preserve the ordering of the element's, i.e. for the rows coming out of OPENJSON to be the same as the
129
129
// element order in the original JSON array.
130
- // Unfortunately, OpenJson with an explicit schema (with the WITH clause) doesn't support this; so we use the variant with the
130
+ // Unfortunately, OPENJSON with an explicit schema (with the WITH clause) doesn't support this; so we use the variant with the
131
131
// default schema, which returns a 'key' column containing the index, and order by that. This also means we need to explicitly
132
- // apply a conversion from the values coming out of OpenJson (always NVARCHAR(MAX)) to the required relational store type.
133
- var openJsonExpression = new TableValuedFunctionExpression ( tableAlias , "OpenJson " , new [ ] { sqlExpression } ) ;
132
+ // apply a conversion from the values coming out of OPENJSON (always NVARCHAR(MAX)) to the required relational store type.
133
+ var openJsonExpression = new TableValuedFunctionExpression ( tableAlias , "OPENJSON " , new [ ] { sqlExpression } ) ;
134
134
135
135
// TODO: When we have metadata to determine if the element is nullable, pass that here to SelectExpression
136
136
var selectExpression = new SelectExpression (
@@ -140,7 +140,7 @@ protected override ShapedQueryExpression TranslateCollection(
140
140
if ( elementTypeMapping is { StoreType : not "nvarchar(max)" } )
141
141
{
142
142
// For columns (where we know the type mapping), we need to overwrite the projection in order to insert a CAST() to the actual
143
- // relational store type we expect out of the JSON array (e.g. OpenJson returns strings, we want datetime2).
143
+ // relational store type we expect out of the JSON array (e.g. OPENJSON returns strings, we want datetime2).
144
144
// For parameters (where we don't yet know the type mapping), we'll need to do that later, after the type mapping has been
145
145
// inferred.
146
146
// TODO: Need to pass through the type mapping API for converting the JSON value (nvarchar) to the relational store type (e.g.
@@ -164,7 +164,7 @@ protected override ShapedQueryExpression TranslateCollection(
164
164
} ) ;
165
165
}
166
166
167
- // Append an ordering for the OpenJson 'key' column, converting it from nvarchar to int.
167
+ // Append an ordering for the OPENJSON 'key' column, converting it from nvarchar to int.
168
168
selectExpression . AppendOrdering (
169
169
new OrderingExpression (
170
170
_sqlExpressionFactory . Convert (
@@ -211,7 +211,7 @@ protected override ShapedQueryExpression TranslateCollection(
211
211
[
212
212
TableValuedFunctionExpression
213
213
{
214
- Name : "OpenJson " , Schema : null , IsBuiltIn : true , Arguments : [ var jsonArrayColumn ]
214
+ Name : "OPENJSON " , Schema : null , IsBuiltIn : true , Arguments : [ var jsonArrayColumn ]
215
215
} openJsonExpression
216
216
] ,
217
217
GroupBy : [ ] ,
@@ -246,7 +246,7 @@ protected override ShapedQueryExpression TranslateCollection(
246
246
if ( shaperExpression is ProjectionBindingExpression projectionBindingExpression
247
247
&& selectExpression . GetProjection ( projectionBindingExpression ) is SqlExpression projection )
248
248
{
249
- // OpenJson 's value column is an nvarchar(max); if this is a collection column whose type mapping is know, the projection
249
+ // OPENJSON 's value column is an nvarchar(max); if this is a collection column whose type mapping is know, the projection
250
250
// contains a CAST node which we unwrap
251
251
var projectionColumn = projection switch
252
252
{
@@ -273,7 +273,7 @@ protected override ShapedQueryExpression TranslateCollection(
273
273
// If we have a type mapping (i.e. translating over a column rather than a parameter), apply any necessary server-side
274
274
// conversions.
275
275
// TODO: This should be part of #30677
276
- // OpenJson 's value column has type nvarchar(max); apply a CAST() unless that's the inferred element type mapping
276
+ // OPENJSON 's value column has type nvarchar(max); apply a CAST() unless that's the inferred element type mapping
277
277
if ( projectionColumn . TypeMapping is { StoreType : not "nvarchar(max)" } typeMapping )
278
278
{
279
279
translation = _sqlExpressionFactory . Convert ( translation , typeMapping . ClrType , typeMapping ) ;
@@ -440,21 +440,21 @@ protected override Expression VisitExtension(Expression expression)
440
440
{
441
441
switch ( expression )
442
442
{
443
- case TableValuedFunctionExpression { Name : "OpenJson " , Schema : null , IsBuiltIn : true } openJsonExpression
443
+ case TableValuedFunctionExpression { Name : "OPENJSON " , Schema : null , IsBuiltIn : true } openJsonExpression
444
444
when InferredTypeMappings . TryGetValue ( ( openJsonExpression , "value" ) , out var typeMapping ) :
445
445
return ApplyTypeMappingsOnOpenJsonExpression ( openJsonExpression , new [ ] { typeMapping } ) ;
446
446
447
- // Above, we applied the type mapping the the parameter that OpenJson accepts as an argument.
447
+ // Above, we applied the type mapping the the parameter that OPENJSON accepts as an argument.
448
448
// But the inferred type mapping also needs to be applied as a SQL conversion on the column projections coming out of the
449
- // SelectExpression containing the OpenJson call. So we set state to know about OpenJson tables and their type mappings
449
+ // SelectExpression containing the OPENJSON call. So we set state to know about OPENJSON tables and their type mappings
450
450
// in the immediate SelectExpression, and continue visiting down (see ColumnExpression visitation below).
451
451
case SelectExpression selectExpression :
452
452
{
453
453
Dictionary < TableExpressionBase , RelationalTypeMapping > ? previousSelectInferredTypeMappings = null ;
454
454
455
455
foreach ( var table in selectExpression . Tables )
456
456
{
457
- if ( table is TableValuedFunctionExpression { Name : "OpenJson " , Schema : null , IsBuiltIn : true } openJsonExpression
457
+ if ( table is TableValuedFunctionExpression { Name : "OPENJSON " , Schema : null , IsBuiltIn : true } openJsonExpression
458
458
&& InferredTypeMappings . TryGetValue ( ( openJsonExpression , "value" ) , out var inferredTypeMapping ) )
459
459
{
460
460
if ( previousSelectInferredTypeMappings is null )
@@ -534,7 +534,7 @@ protected virtual TableValuedFunctionExpression ApplyTypeMappingsOnOpenJsonExpre
534
534
/// </summary>
535
535
public virtual SqlExpression ApplyTypeMappingOnColumn ( ColumnExpression columnExpression , RelationalTypeMapping typeMapping )
536
536
// TODO: this should be part of #30677
537
- // OpenJson 's value column has type nvarchar(max); apply a CAST() unless that's the inferred element type mapping
537
+ // OPENJSON 's value column has type nvarchar(max); apply a CAST() unless that's the inferred element type mapping
538
538
=> typeMapping . StoreType is "nvarchar(max)"
539
539
? columnExpression
540
540
: _sqlExpressionFactory . Convert ( columnExpression , typeMapping . ClrType , typeMapping ) ;
0 commit comments