@@ -320,6 +320,72 @@ WHERE JSON_UNQUOTE(`j`.`CustomerElement`) = 'foo'
320320
321321 #region Functions
322322
323+ [ ConditionalFact ]
324+ [ SupportedServerVersionCondition ( nameof ( ServerVersionSupport . JsonOverlaps ) ) ]
325+ public void JsonOverlaps_with_json_element ( )
326+ {
327+ using var ctx = CreateContext ( ) ;
328+ var element = JsonDocument . Parse ( @"{""Name"": ""Joe"", ""Age"": -1}" ) . RootElement ;
329+ var count = ctx . JsonEntities . Count ( e =>
330+ EF . Functions . JsonOverlaps ( e . CustomerElement , element ) ) ;
331+
332+ Assert . Equal ( 1 , count ) ;
333+ AssertSql (
334+ $@ "@__element_1='{{""Name"":""Joe"",""Age"":-1}}' (Nullable = false) (Size = 4000)
335+
336+ SELECT COUNT(*)
337+ FROM `JsonEntities` AS `j`
338+ WHERE JSON_OVERLAPS(`j`.`CustomerElement`, { InsertJsonConvert ( "@__element_1" ) } )" ) ;
339+ }
340+
341+ [ ConditionalFact ]
342+ [ SupportedServerVersionCondition ( nameof ( ServerVersionSupport . JsonOverlaps ) ) ]
343+ public void JsonOverlaps_with_string ( )
344+ {
345+ using var ctx = CreateContext ( ) ;
346+ var count = ctx . JsonEntities . Count ( e =>
347+ EF . Functions . JsonOverlaps ( e . CustomerElement , @"{""Name"": ""Joe"", ""Age"": -1}" ) ) ;
348+
349+ Assert . Equal ( 1 , count ) ;
350+ AssertSql (
351+ @"SELECT COUNT(*)
352+ FROM `JsonEntities` AS `j`
353+ WHERE JSON_OVERLAPS(`j`.`CustomerElement`, '{""Name"": ""Joe"", ""Age"": -1}')" ) ;
354+ }
355+
356+ [ ConditionalFact ]
357+ [ SupportedServerVersionCondition ( nameof ( ServerVersionSupport . JsonOverlaps ) ) ]
358+ public void JsonOverlaps_using_JsonExtract_with_json_element ( )
359+ {
360+ using var ctx = CreateContext ( ) ;
361+ var element = JsonDocument . Parse ( @"[3,-1]" ) . RootElement ;
362+ var count = ctx . JsonEntities . Count ( e =>
363+ EF . Functions . JsonOverlaps ( EF . Functions . JsonExtract < string [ ] > ( e . CustomerElement , "$.Statistics.Nested.IntArray" ) , element ) ) ;
364+
365+ Assert . Equal ( 1 , count ) ;
366+ AssertSql (
367+ $@ "@__element_1='[3,-1]' (Nullable = false) (Size = 4000)
368+
369+ SELECT COUNT(*)
370+ FROM `JsonEntities` AS `j`
371+ WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), { InsertJsonConvert ( "@__element_1" ) } )" ) ;
372+ }
373+
374+ [ ConditionalFact ]
375+ [ SupportedServerVersionCondition ( nameof ( ServerVersionSupport . JsonOverlaps ) ) ]
376+ public void JsonOverlaps_using_JsonExtract_with_json_string ( )
377+ {
378+ using var ctx = CreateContext ( ) ;
379+ var count = ctx . JsonEntities . Count ( e =>
380+ EF . Functions . JsonOverlaps ( EF . Functions . JsonExtract < string [ ] > ( e . CustomerElement , "$.Statistics.Nested.IntArray" ) , @"[3,-1]" ) ) ;
381+
382+ Assert . Equal ( 1 , count ) ;
383+ AssertSql (
384+ $@ "SELECT COUNT(*)
385+ FROM `JsonEntities` AS `j`
386+ WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), '[3,-1]')" ) ;
387+ }
388+
323389 [ Fact ]
324390 public void JsonContains_with_json_element ( )
325391 {
0 commit comments