From d6ad6bc5da75a8e77dfe305f31c19b1b2053d5f1 Mon Sep 17 00:00:00 2001 From: Fabian Blechschmidt Date: Mon, 27 May 2024 12:48:13 +0200 Subject: [PATCH 1/4] Rework QueryTests to have a baseline and track broken tests --- tests/QueryTest.php | 141 ++++++++++++++------------- tests/data/baselineFailedQueries.txt | 34 +++++++ 2 files changed, 109 insertions(+), 66 deletions(-) create mode 100644 tests/data/baselineFailedQueries.txt diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 9c70b83..13c6ac4 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -17,10 +17,16 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -use const STDERR; - class QueryTest extends TestCase { + static array $baselineFailedQueries; + + public static function setUpBeforeClass(): void + { + parent::setUpBeforeClass(); + self::$baselineFailedQueries = array_map('trim', file(__DIR__.'/data/baselineFailedQueries.txt')); + } + /** * This method aims to test the current implementation against * all queries listed on https://cburgmer.github.io/json-path-comparison/ @@ -70,21 +76,24 @@ public function testQueries( // assert in these cases. There might be still some false positives // (e.g. multidimensional comparisons), but that's okay, I guess. Maybe, // we can also find a way around that in the future. + $message = "==========================\n"; + $message .= "Query: {$query}\n\nMore information: {$url}\n"; + $message .= "==========================\n\n"; self::assertEqualsCanonicalizing( \json_decode($consensus, true), - \json_decode($results, true) + \json_decode($results, true), + $message ); } catch (ExpectationFailedException) { - $e = $e->getComparisonFailure(); - - \fwrite(STDERR, "==========================\n"); - \fwrite(STDERR, "Query: {$query}\n\n{$e->toString()}\nMore information: {$url}\n"); - \fwrite(STDERR, "==========================\n\n"); + if (!in_array($id, self::$baselineFailedQueries, true)) { + throw new ExpectationFailedException( + $e->getMessage()."\nQuery: {$query}\n\nMore information: {$url}", + $e->getComparisonFailure() + ); + } } } catch (JSONPathException $e) { - \fwrite(STDERR, "==========================\n"); - \fwrite(STDERR, "Query: {$query}\n\n{$e->getMessage()}\n"); - \fwrite(STDERR, "==========================\n\n"); + // ignore } catch (RuntimeException) { // ignore } @@ -579,7 +588,7 @@ public static function queryDataProvider(): array 'bracket_notation_with_two_literals_separated_by_dot', '$[\'two\'.\'some\']', '{"one":{"key":"value"},"two":{"some":"more","key":"other value"},"two.some":"42","two\'.\'some":"43' - . '"}', + .'"}', '', ], [ // data set #77 - unknown consensus @@ -676,7 +685,7 @@ public static function queryDataProvider(): array 'dot_notation_after_bracket_notation_after_recursive_descent', '$..[1].key', '{"k":[{"key":"some value"},{"key":42}],"kk":[[{"key":100},{"key":200},{"key":300}],[{"key":400},{"k' - . 'ey":500},{"key":600}]],"key":[0,1]}', + .'ey":500},{"key":600}]],"key":[0,1]}', '[200,42,500]', ], [ // data set #93 @@ -707,17 +716,17 @@ public static function queryDataProvider(): array 'dot_notation_after_recursive_descent', '$..key', '{"object":{"key":"value","array":[{"key":"something"},{"key":{"key":"russian dolls"}}]},"key":"top"' - . '}', + .'}', '["russian dolls","something","top","value",{"key":"russian dolls"}]', ], [ // data set #98 'dot_notation_after_recursive_descent_after_dot_notation', '$.store..price', '{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","p' - . 'rice":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},' - . '{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price"' - . ':8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-' - . '395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}', + .'rice":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},' + .'{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price"' + .':8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-' + .'395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}', '[12.99,19.95,22.99,8.95,8.99]', ], [ // data set #99 @@ -784,7 +793,7 @@ public static function queryDataProvider(): array 'dot_notation_with_double_quotes_after_recursive_descent', '$.."key"', '{"object":{"key":"value","\\"key\\"":100,"array":[{"key":"something","\\"key\\"":0},{"key":{"key":"' - . 'russian dolls"},"\\"key\\"":{"\\"key\\"":99}}]},"key":"top","\\"key\\"":42}', + .'russian dolls"},"\\"key\\"":{"\\"key\\"":99}}]},"key":"top","\\"key\\"":42}', '', ], [ // data set #110 - unknown consensus @@ -863,7 +872,7 @@ public static function queryDataProvider(): array 'dot_notation_with_single_quotes_after_recursive_descent', '$..\'key\'', '{"object":{"key":"value","\'key\'":100,"array":[{"key":"something","\'key\'":0},{"key":{"key":"russ' - . 'ian dolls"},"\'key\'":{"\'key\'":99}}]},"key":"top","\'key\'":42}', + .'ian dolls"},"\'key\'":{"\'key\'":99}}]},"key":"top","\'key\'":42}', '', ], [ // data set #123 - unknown consensus @@ -936,7 +945,7 @@ public static function queryDataProvider(): array 'filter_expression_after_dot_notation_with_wildcard_after_recursive_descent', '$..*[?(@.id>2)]', '[{"complext":{"one":[{"name":"first","id":1},{"name":"next","id":2},{"name":"another","id":3},{"nam' - . 'e":"more","id":4}],"more":{"name":"next to last","id":5}}},{"name":"last","id":6}]', + .'e":"more","id":4}],"more":{"name":"next to last","id":5}}},{"name":"last","id":6}]', '[{"id":3,"name":"another"},{"id":4,"name":"more"},{"id":5,"name":"next to last"}]', ], [ // data set #135 - unknown consensus, fallback to Proposal A @@ -967,14 +976,14 @@ public static function queryDataProvider(): array 'filter_expression_with_boolean_and_operator_and_value_false', '$[?(@.key>0 && false)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - . '"key":-1},{"key":0},{"key":""}]', + .'"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #140 - unknown consensus 'filter_expression_with_boolean_and_operator_and_value_true', '$[?(@.key>0 && true)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - . '"key":-1},{"key":0},{"key":""}]', + .'"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #141 - unknown consensus, fallback to Proposal A @@ -987,21 +996,21 @@ public static function queryDataProvider(): array 'filter_expression_with_boolean_or_operator_and_value_false', '$[?(@.key>0 || false)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - . '"key":-1},{"key":0},{"key":""}]', + .'"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #143 - unknown consensus 'filter_expression_with_boolean_or_operator_and_value_true', '$[?(@.key>0 || true)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - . '"key":-1},{"key":0},{"key":""}]', + .'"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #144 'filter_expression_with_bracket_notation', '$[?(@[\'key\']==42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"some":"value"}]', + .'{"some":"value"}]', '[{"key":42}]', ], [ // data set #145 @@ -1038,14 +1047,14 @@ public static function queryDataProvider(): array 'filter_expression_with_different_grouped_operators', '$[?(@.a && (@.b || @.c))]', '[{"a":true},{"a":true,"b":true},{"a":true,"b":true,"c":true},{"b":true,"c":true},{"a":true,"c":true' - . '},{"c":true},{"b":true}]', + .'},{"c":true},{"b":true}]', '[{"a":true,"b":true},{"a":true,"b":true,"c":true},{"a":true,"c":true}]', ], [ // data set #151 - unknown consensus 'filter_expression_with_different_ungrouped_operators', '$[?(@.a && @.b || @.c)]', '[{"a":true,"b":true},{"a":true,"b":true,"c":true},{"b":true,"c":true},{"a":true,"c":true},{"a":true' - . '},{"b":true},{"c":true},{"d":true},{}]', + .'},{"b":true},{"c":true},{"d":true},{}]', '', ], [ // data set #152 - unknown consensus @@ -1064,16 +1073,16 @@ public static function queryDataProvider(): array 'filter_expression_with_equals', '$[?(@.key==42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '[{"key":42}]', ], [ // data set #155 - unknown consensus 'filter_expression_with_equals_array', '$[?(@.d==["v1","v2"])]', '[{"d":["v1","v2"]},{"d":["a","b"]},{"d":"v1"},{"d":"v2"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d"' - . ':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' - . '"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', + .':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' + .'"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', '', ], [ // data set #156 - unknown consensus @@ -1092,8 +1101,8 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_array_with_single_quotes', '$[?(@.d==[\'v1\',\'v2\'])]', '[{"d":["v1","v2"]},{"d":["a","b"]},{"d":"v1"},{"d":"v2"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d"' - . ':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' - . '"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', + .':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' + .'"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', '', ], [ // data set #159 - unknown consensus @@ -1106,14 +1115,14 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_false', '$[?(@.key==false)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":false}]', ], [ // data set #161 - unknown consensus, fallback to Proposal A 'filter_expression_with_equals_null', '$[?(@.key==null)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":null}]', ], [ // data set #162 - unknown consensus @@ -1150,7 +1159,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_object', '$[?(@.d=={"k":"v"})]', '[{"d":{"k":"v"}},{"d":{"a":"b"}},{"d":"k"},{"d":"v"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d":0},' - . '{"d":1},{"d":"[object Object]"},{"d":"{\\"k\\": \\"v\\"}"},{"d":"{\\"k\\":\\"v\\"}"},"v"]', + .'{"d":1},{"d":"[object Object]"},{"d":"{\\"k\\": \\"v\\"}"},{"d":"{\\"k\\":\\"v\\"}"},"v"]', '', ], [ // data set #168 - unknown consensus, fallback to Proposal A @@ -1169,7 +1178,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_on_object', '$[?(@.key==42)]', '{"a":{"key":0},"b":{"key":42},"c":{"key":-1},"d":{"key":41},"e":{"key":43},"f":{"key":42.0001},"g":' - . '{"key":41.9999},"h":{"key":100},"i":{"some":"value"}}', + .'{"key":41.9999},"h":{"key":100},"i":{"some":"value"}}', '[{"key":42}]', ], [ // data set #171 - unknown consensus, fallback to Proposal A @@ -1182,8 +1191,8 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_string', '$[?(@.key=="value")]', '[{"key":"some"},{"key":"value"},{"key":null},{"key":0},{"key":1},{"key":-1},{"key":""},{"key":{}},{' - . '"key":[]},{"key":"valuemore"},{"key":"morevalue"},{"key":["value"]},{"key":{"some":"value"}},{"key"' - . ':{"key":"value"}},{"some":"value"}]', + .'"key":[]},{"key":"valuemore"},{"key":"morevalue"},{"key":["value"]},{"key":{"some":"value"}},{"key"' + .':{"key":"value"}},{"some":"value"}]', '[{"key":"value"}]', ], [ // data set #173 @@ -1208,7 +1217,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_true', '$[?(@.key==true)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":true}]', ], [ // data set #177 - unknown consensus, fallback to Proposal A @@ -1221,14 +1230,14 @@ public static function queryDataProvider(): array 'filter_expression_with_greater_than', '$[?(@.key>42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":43},{"key":42.0001},{"key":100}]', ], [ // data set #179 - unknown consensus, fallback to Proposal A 'filter_expression_with_greater_than_or_equal', '$[?(@.key>=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":42},{"key":43},{"key":42.0001},{"key":100}]', ], [ // data set #180 - unknown consensus @@ -1247,14 +1256,14 @@ public static function queryDataProvider(): array 'filter_expression_with_less_than', '$[?(@.key<42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":41},{"key":41.9999}]', ], [ // data set #183 - unknown consensus, fallback to Proposal A 'filter_expression_with_less_than_or_equal', '$[?(@.key<=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":41.9999}]', ], [ // data set #184 - unknown consensus @@ -1267,33 +1276,33 @@ public static function queryDataProvider(): array 'filter_expression_with_negation_and_equals', '$[?(!(@.key==42))]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{"key":"43"' - . '},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', ], [ // data set #186 - unknown consensus, fallback to Proposal A 'filter_expression_with_negation_and_less_than', '$[?(!(@.key<42))]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":42},{"key":43},{"key":42.0001},{"key":100},{"key":"43"},{"key":"42"},{"key":"41"},{"key":"v' - . 'alue"},{"some":"value"}]', + .'alue"},{"some":"value"}]', ], [ // data set #187 - unknown consensus, fallback to Proposal A 'filter_expression_with_not_equals', '$[?(@.key!=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{' - . '"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"key":[42]},{' - . '"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"key":[42]},{' + .'"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', ], [ // data set #188 - unknown consensus 'filter_expression_with_regular_expression', '$[?(@.name=~/hello.*/)]', '[{"name":"hullo world"},{"name":"hello world"},{"name":"yes hello world"},{"name":"HELLO WORLD"},{"' - . 'name":"good bye"}]', + .'name":"good bye"}]', '', ], [ // data set #189 - unknown consensus @@ -1312,15 +1321,15 @@ public static function queryDataProvider(): array 'filter_expression_with_single_equal', '$[?(@.key=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #192 - unknown consensus 'filter_expression_with_subfilter', '$[?(@.a[?(@.price>10)])]', '[{"a":[{"price":1},{"price":3}]},{"a":[{"price":11}]},{"a":[{"price":8},{"price":12},{"price":3}]},' - . '{"a":[]}]', + .'{"a":[]}]', '', ], [ // data set #193 @@ -1345,17 +1354,17 @@ public static function queryDataProvider(): array 'filter_expression_with_triple_equal', '$[?(@.key===42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #197 - unknown consensus, fallback to Proposal A 'filter_expression_with_value', '$[?(@.key)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0},{"key":1},{"key":-1},' - . '{"key":42},{"key":{}},{"key":[]}]', + .'{"key":42},{"key":{}},{"key":[]}]', ], [ // data set #198 - unknown consensus, fallback to Proposal A 'filter_expression_with_value_after_dot_notation_with_wildcard_on_array_of_objects', @@ -1379,7 +1388,7 @@ public static function queryDataProvider(): array 'filter_expression_with_value_from_recursive_descent', '$[?(@..child)]', '[{"key":[{"child":1},{"child":2}]},{"key":[{"child":2}]},{"key":[{}]},{"key":[{"something":42}]},{}' - . ']', + .']', '', ], [ // data set #202 - unknown consensus @@ -1398,15 +1407,15 @@ public static function queryDataProvider(): array 'filter_expression_without_parens', '$[?@.key==42]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #205 - unknown consensus, fallback to Proposal A 'filter_expression_without_value', '$[?(!@.key)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"some":"some value"}]', ], [ // data set #206 - unknown consensus @@ -1497,7 +1506,7 @@ public static function queryDataProvider(): array 'union_with_keys_after_recursive_descent', '$..[\'c\',\'d\']', '[{"c":"cc1","d":"dd1","e":"ee1"},{"c":"cc2","child":{"d":"dd2"}},{"c":"cc3"},{"d":"dd4"},{"child":{' - . '"c":"cc5"}}]', + .'"c":"cc5"}}]', '["cc1","cc2","cc3","cc5","dd1","dd2","dd4"]', ], [ // data set #221 diff --git a/tests/data/baselineFailedQueries.txt b/tests/data/baselineFailedQueries.txt new file mode 100644 index 0000000..16e26eb --- /dev/null +++ b/tests/data/baselineFailedQueries.txt @@ -0,0 +1,34 @@ +array_slice_with_large_number_for_end_and_negative_step +array_slice_with_large_number_for_start_end_negative_step +array_slice_with_negative_step +array_slice_with_negative_step_on_partially_overlapping_array +bracket_notation_with_negative_number_on_short_array +bracket_notation_with_number_on_object +bracket_notation_with_quoted_escaped_backslash +bracket_notation_with_quoted_escaped_single_quote +bracket_notation_with_quoted_special_characters_combined +bracket_notation_with_quoted_wildcard_literal_on_object_without_key +bracket_notation_with_wildcard_after_recursive_descent +dot_notation_with_number +dot_notation_with_number_-1 +dot_notation_with_wildcard_after_recursive_descent +filter_expression_with_boolean_and_operator +filter_expression_with_boolean_or_operator +filter_expression_with_bracket_notation_with_-1 +filter_expression_with_equals +filter_expression_with_equals_false +filter_expression_with_equals_null +filter_expression_with_equals_number_with_fraction +filter_expression_with_equals_true +filter_expression_with_equals_with_root_reference +filter_expression_with_greater_than +filter_expression_with_greater_than_or_equal +filter_expression_with_less_than +filter_expression_with_less_than_or_equal +filter_expression_with_not_equals +filter_expression_with_subpaths +filter_expression_with_value +script_expression +union_with_filter +union_with_repeated_matches_after_dot_notation_with_wildcard +union_with_slice_and_number From d8ed226b2e7456087b0cf17dd8a076408f3c9f53 Mon Sep 17 00:00:00 2001 From: Fabian Blechschmidt Date: Mon, 27 May 2024 13:16:28 +0200 Subject: [PATCH 2/4] Fixes #20 --- src/Filters/QueryMatchFilter.php | 9 +++++++-- tests/data/baselineFailedQueries.txt | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Filters/QueryMatchFilter.php b/src/Filters/QueryMatchFilter.php index 13b8ee4..42ad167 100644 --- a/src/Filters/QueryMatchFilter.php +++ b/src/Filters/QueryMatchFilter.php @@ -9,6 +9,7 @@ namespace Flow\JSONPath\Filters; use Flow\JSONPath\AccessHelper; +use Flow\JSONPath\JSONPath; use RuntimeException; class QueryMatchFilter extends AbstractFilter @@ -20,7 +21,7 @@ class QueryMatchFilter extends AbstractFilter public function filter($collection): array { - \preg_match('/^' . static::MATCH_QUERY_OPERATORS . '$/x', $this->token->value, $matches); + \preg_match('/^'.static::MATCH_QUERY_OPERATORS.'$/x', $this->token->value, $matches); if (!isset($matches[1])) { throw new RuntimeException('Malformed filter query'); @@ -59,9 +60,13 @@ public function filter($collection): array $return = []; foreach ($collection as $value) { + $value1 = null; if (AccessHelper::keyExists($value, $key, $this->magicIsAllowed)) { $value1 = AccessHelper::getValue($value, $key, $this->magicIsAllowed); - + } elseif (str_contains($key, '.')) { + $value1 = (new JSONPath($value))->find($key)->getData()[0]; + } + if ($value1) { if ($operator === null && $value1) { $return[] = $value; } diff --git a/tests/data/baselineFailedQueries.txt b/tests/data/baselineFailedQueries.txt index 16e26eb..75ab837 100644 --- a/tests/data/baselineFailedQueries.txt +++ b/tests/data/baselineFailedQueries.txt @@ -26,7 +26,6 @@ filter_expression_with_greater_than_or_equal filter_expression_with_less_than filter_expression_with_less_than_or_equal filter_expression_with_not_equals -filter_expression_with_subpaths filter_expression_with_value script_expression union_with_filter From bf3b43215a5345fcbf4cc2677fbb329dac298b2b Mon Sep 17 00:00:00 2001 From: Fabian Blechschmidt Date: Mon, 27 May 2024 13:21:24 +0200 Subject: [PATCH 3/4] Fixes #20 /var/www/html/src/Filters/QueryMatchFilter.php:67 Undefined array key 0 --- src/Filters/QueryMatchFilter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Filters/QueryMatchFilter.php b/src/Filters/QueryMatchFilter.php index 42ad167..8a1dfd9 100644 --- a/src/Filters/QueryMatchFilter.php +++ b/src/Filters/QueryMatchFilter.php @@ -64,7 +64,7 @@ public function filter($collection): array if (AccessHelper::keyExists($value, $key, $this->magicIsAllowed)) { $value1 = AccessHelper::getValue($value, $key, $this->magicIsAllowed); } elseif (str_contains($key, '.')) { - $value1 = (new JSONPath($value))->find($key)->getData()[0]; + $value1 = (new JSONPath($value))->find($key)->getData()[0] ?? ''; } if ($value1) { if ($operator === null && $value1) { From 25c7c11a8dcdd91e62b7db306a4903e562556991 Mon Sep 17 00:00:00 2001 From: Sascha Greuel Date: Sat, 1 Jun 2024 10:26:39 +0200 Subject: [PATCH 4/4] Code Style --- src/Filters/QueryMatchFilter.php | 4 +- tests/QueryTest.php | 118 +++++++++++++++---------------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Filters/QueryMatchFilter.php b/src/Filters/QueryMatchFilter.php index 8a1dfd9..59caa72 100644 --- a/src/Filters/QueryMatchFilter.php +++ b/src/Filters/QueryMatchFilter.php @@ -21,7 +21,7 @@ class QueryMatchFilter extends AbstractFilter public function filter($collection): array { - \preg_match('/^'.static::MATCH_QUERY_OPERATORS.'$/x', $this->token->value, $matches); + \preg_match('/^' . static::MATCH_QUERY_OPERATORS . '$/x', $this->token->value, $matches); if (!isset($matches[1])) { throw new RuntimeException('Malformed filter query'); @@ -63,7 +63,7 @@ public function filter($collection): array $value1 = null; if (AccessHelper::keyExists($value, $key, $this->magicIsAllowed)) { $value1 = AccessHelper::getValue($value, $key, $this->magicIsAllowed); - } elseif (str_contains($key, '.')) { + } elseif (\str_contains($key, '.')) { $value1 = (new JSONPath($value))->find($key)->getData()[0] ?? ''; } if ($value1) { diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 13c6ac4..942460a 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -19,12 +19,12 @@ class QueryTest extends TestCase { - static array $baselineFailedQueries; + public static array $baselineFailedQueries; public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - self::$baselineFailedQueries = array_map('trim', file(__DIR__.'/data/baselineFailedQueries.txt')); + self::$baselineFailedQueries = \array_map('trim', \file(__DIR__ . '/data/baselineFailedQueries.txt')); } /** @@ -85,9 +85,9 @@ public function testQueries( $message ); } catch (ExpectationFailedException) { - if (!in_array($id, self::$baselineFailedQueries, true)) { + if (!\in_array($id, self::$baselineFailedQueries, true)) { throw new ExpectationFailedException( - $e->getMessage()."\nQuery: {$query}\n\nMore information: {$url}", + $e->getMessage() . "\nQuery: {$query}\n\nMore information: {$url}", $e->getComparisonFailure() ); } @@ -588,7 +588,7 @@ public static function queryDataProvider(): array 'bracket_notation_with_two_literals_separated_by_dot', '$[\'two\'.\'some\']', '{"one":{"key":"value"},"two":{"some":"more","key":"other value"},"two.some":"42","two\'.\'some":"43' - .'"}', + . '"}', '', ], [ // data set #77 - unknown consensus @@ -685,7 +685,7 @@ public static function queryDataProvider(): array 'dot_notation_after_bracket_notation_after_recursive_descent', '$..[1].key', '{"k":[{"key":"some value"},{"key":42}],"kk":[[{"key":100},{"key":200},{"key":300}],[{"key":400},{"k' - .'ey":500},{"key":600}]],"key":[0,1]}', + . 'ey":500},{"key":600}]],"key":[0,1]}', '[200,42,500]', ], [ // data set #93 @@ -716,17 +716,17 @@ public static function queryDataProvider(): array 'dot_notation_after_recursive_descent', '$..key', '{"object":{"key":"value","array":[{"key":"something"},{"key":{"key":"russian dolls"}}]},"key":"top"' - .'}', + . '}', '["russian dolls","something","top","value",{"key":"russian dolls"}]', ], [ // data set #98 'dot_notation_after_recursive_descent_after_dot_notation', '$.store..price', '{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","p' - .'rice":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},' - .'{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price"' - .':8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-' - .'395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}', + . 'rice":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},' + . '{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price"' + . ':8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-' + . '395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}', '[12.99,19.95,22.99,8.95,8.99]', ], [ // data set #99 @@ -793,7 +793,7 @@ public static function queryDataProvider(): array 'dot_notation_with_double_quotes_after_recursive_descent', '$.."key"', '{"object":{"key":"value","\\"key\\"":100,"array":[{"key":"something","\\"key\\"":0},{"key":{"key":"' - .'russian dolls"},"\\"key\\"":{"\\"key\\"":99}}]},"key":"top","\\"key\\"":42}', + . 'russian dolls"},"\\"key\\"":{"\\"key\\"":99}}]},"key":"top","\\"key\\"":42}', '', ], [ // data set #110 - unknown consensus @@ -872,7 +872,7 @@ public static function queryDataProvider(): array 'dot_notation_with_single_quotes_after_recursive_descent', '$..\'key\'', '{"object":{"key":"value","\'key\'":100,"array":[{"key":"something","\'key\'":0},{"key":{"key":"russ' - .'ian dolls"},"\'key\'":{"\'key\'":99}}]},"key":"top","\'key\'":42}', + . 'ian dolls"},"\'key\'":{"\'key\'":99}}]},"key":"top","\'key\'":42}', '', ], [ // data set #123 - unknown consensus @@ -945,7 +945,7 @@ public static function queryDataProvider(): array 'filter_expression_after_dot_notation_with_wildcard_after_recursive_descent', '$..*[?(@.id>2)]', '[{"complext":{"one":[{"name":"first","id":1},{"name":"next","id":2},{"name":"another","id":3},{"nam' - .'e":"more","id":4}],"more":{"name":"next to last","id":5}}},{"name":"last","id":6}]', + . 'e":"more","id":4}],"more":{"name":"next to last","id":5}}},{"name":"last","id":6}]', '[{"id":3,"name":"another"},{"id":4,"name":"more"},{"id":5,"name":"next to last"}]', ], [ // data set #135 - unknown consensus, fallback to Proposal A @@ -976,14 +976,14 @@ public static function queryDataProvider(): array 'filter_expression_with_boolean_and_operator_and_value_false', '$[?(@.key>0 && false)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - .'"key":-1},{"key":0},{"key":""}]', + . '"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #140 - unknown consensus 'filter_expression_with_boolean_and_operator_and_value_true', '$[?(@.key>0 && true)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - .'"key":-1},{"key":0},{"key":""}]', + . '"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #141 - unknown consensus, fallback to Proposal A @@ -996,21 +996,21 @@ public static function queryDataProvider(): array 'filter_expression_with_boolean_or_operator_and_value_false', '$[?(@.key>0 || false)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - .'"key":-1},{"key":0},{"key":""}]', + . '"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #143 - unknown consensus 'filter_expression_with_boolean_or_operator_and_value_true', '$[?(@.key>0 || true)]', '[{"key":1},{"key":3},{"key":"nice"},{"key":true},{"key":null},{"key":false},{"key":{}},{"key":[]},{' - .'"key":-1},{"key":0},{"key":""}]', + . '"key":-1},{"key":0},{"key":""}]', '', ], [ // data set #144 'filter_expression_with_bracket_notation', '$[?(@[\'key\']==42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"some":"value"}]', + . '{"some":"value"}]', '[{"key":42}]', ], [ // data set #145 @@ -1047,14 +1047,14 @@ public static function queryDataProvider(): array 'filter_expression_with_different_grouped_operators', '$[?(@.a && (@.b || @.c))]', '[{"a":true},{"a":true,"b":true},{"a":true,"b":true,"c":true},{"b":true,"c":true},{"a":true,"c":true' - .'},{"c":true},{"b":true}]', + . '},{"c":true},{"b":true}]', '[{"a":true,"b":true},{"a":true,"b":true,"c":true},{"a":true,"c":true}]', ], [ // data set #151 - unknown consensus 'filter_expression_with_different_ungrouped_operators', '$[?(@.a && @.b || @.c)]', '[{"a":true,"b":true},{"a":true,"b":true,"c":true},{"b":true,"c":true},{"a":true,"c":true},{"a":true' - .'},{"b":true},{"c":true},{"d":true},{}]', + . '},{"b":true},{"c":true},{"d":true},{}]', '', ], [ // data set #152 - unknown consensus @@ -1073,16 +1073,16 @@ public static function queryDataProvider(): array 'filter_expression_with_equals', '$[?(@.key==42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '[{"key":42}]', ], [ // data set #155 - unknown consensus 'filter_expression_with_equals_array', '$[?(@.d==["v1","v2"])]', '[{"d":["v1","v2"]},{"d":["a","b"]},{"d":"v1"},{"d":"v2"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d"' - .':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' - .'"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', + . ':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' + . '"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', '', ], [ // data set #156 - unknown consensus @@ -1101,8 +1101,8 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_array_with_single_quotes', '$[?(@.d==[\'v1\',\'v2\'])]', '[{"d":["v1","v2"]},{"d":["a","b"]},{"d":"v1"},{"d":"v2"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d"' - .':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' - .'"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', + . ':0},{"d":1},{"d":"[\'v1\',\'v2\']"},{"d":"[\'v1\', \'v2\']"},{"d":"v1,v2"},{"d":"[\\"v1\\", \\"v2\\' + . '"]"},{"d":"[\\"v1\\",\\"v2\\"]"}]', '', ], [ // data set #159 - unknown consensus @@ -1115,14 +1115,14 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_false', '$[?(@.key==false)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":false}]', ], [ // data set #161 - unknown consensus, fallback to Proposal A 'filter_expression_with_equals_null', '$[?(@.key==null)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":null}]', ], [ // data set #162 - unknown consensus @@ -1159,7 +1159,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_object', '$[?(@.d=={"k":"v"})]', '[{"d":{"k":"v"}},{"d":{"a":"b"}},{"d":"k"},{"d":"v"},{"d":{}},{"d":[]},{"d":null},{"d":-1},{"d":0},' - .'{"d":1},{"d":"[object Object]"},{"d":"{\\"k\\": \\"v\\"}"},{"d":"{\\"k\\":\\"v\\"}"},"v"]', + . '{"d":1},{"d":"[object Object]"},{"d":"{\\"k\\": \\"v\\"}"},{"d":"{\\"k\\":\\"v\\"}"},"v"]', '', ], [ // data set #168 - unknown consensus, fallback to Proposal A @@ -1178,7 +1178,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_on_object', '$[?(@.key==42)]', '{"a":{"key":0},"b":{"key":42},"c":{"key":-1},"d":{"key":41},"e":{"key":43},"f":{"key":42.0001},"g":' - .'{"key":41.9999},"h":{"key":100},"i":{"some":"value"}}', + . '{"key":41.9999},"h":{"key":100},"i":{"some":"value"}}', '[{"key":42}]', ], [ // data set #171 - unknown consensus, fallback to Proposal A @@ -1191,8 +1191,8 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_string', '$[?(@.key=="value")]', '[{"key":"some"},{"key":"value"},{"key":null},{"key":0},{"key":1},{"key":-1},{"key":""},{"key":{}},{' - .'"key":[]},{"key":"valuemore"},{"key":"morevalue"},{"key":["value"]},{"key":{"some":"value"}},{"key"' - .':{"key":"value"}},{"some":"value"}]', + . '"key":[]},{"key":"valuemore"},{"key":"morevalue"},{"key":["value"]},{"key":{"some":"value"}},{"key"' + . ':{"key":"value"}},{"some":"value"}]', '[{"key":"value"}]', ], [ // data set #173 @@ -1217,7 +1217,7 @@ public static function queryDataProvider(): array 'filter_expression_with_equals_true', '$[?(@.key==true)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":true}]', ], [ // data set #177 - unknown consensus, fallback to Proposal A @@ -1230,14 +1230,14 @@ public static function queryDataProvider(): array 'filter_expression_with_greater_than', '$[?(@.key>42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":43},{"key":42.0001},{"key":100}]', ], [ // data set #179 - unknown consensus, fallback to Proposal A 'filter_expression_with_greater_than_or_equal', '$[?(@.key>=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":42},{"key":43},{"key":42.0001},{"key":100}]', ], [ // data set #180 - unknown consensus @@ -1256,14 +1256,14 @@ public static function queryDataProvider(): array 'filter_expression_with_less_than', '$[?(@.key<42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":41},{"key":41.9999}]', ], [ // data set #183 - unknown consensus, fallback to Proposal A 'filter_expression_with_less_than_or_equal', '$[?(@.key<=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":41.9999}]', ], [ // data set #184 - unknown consensus @@ -1276,33 +1276,33 @@ public static function queryDataProvider(): array 'filter_expression_with_negation_and_equals', '$[?(!(@.key==42))]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{"key":"43"' - .'},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', ], [ // data set #186 - unknown consensus, fallback to Proposal A 'filter_expression_with_negation_and_less_than', '$[?(!(@.key<42))]', '[{"key":0},{"key":42},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},' - .'{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', + . '{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"},{"some":"value"}]', '[{"key":42},{"key":43},{"key":42.0001},{"key":100},{"key":"43"},{"key":"42"},{"key":"41"},{"key":"v' - .'alue"},{"some":"value"}]', + . 'alue"},{"some":"value"}]', ], [ // data set #187 - unknown consensus, fallback to Proposal A 'filter_expression_with_not_equals', '$[?(@.key!=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '[{"key":0},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{' - .'"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"key":[42]},{' - .'"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . '"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"key":[42]},{' + . '"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', ], [ // data set #188 - unknown consensus 'filter_expression_with_regular_expression', '$[?(@.name=~/hello.*/)]', '[{"name":"hullo world"},{"name":"hello world"},{"name":"yes hello world"},{"name":"HELLO WORLD"},{"' - .'name":"good bye"}]', + . 'name":"good bye"}]', '', ], [ // data set #189 - unknown consensus @@ -1321,15 +1321,15 @@ public static function queryDataProvider(): array 'filter_expression_with_single_equal', '$[?(@.key=42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #192 - unknown consensus 'filter_expression_with_subfilter', '$[?(@.a[?(@.price>10)])]', '[{"a":[{"price":1},{"price":3}]},{"a":[{"price":11}]},{"a":[{"price":8},{"price":12},{"price":3}]},' - .'{"a":[]}]', + . '{"a":[]}]', '', ], [ // data set #193 @@ -1354,17 +1354,17 @@ public static function queryDataProvider(): array 'filter_expression_with_triple_equal', '$[?(@.key===42)]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #197 - unknown consensus, fallback to Proposal A 'filter_expression_with_value', '$[?(@.key)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0},{"key":1},{"key":-1},' - .'{"key":42},{"key":{}},{"key":[]}]', + . '{"key":42},{"key":{}},{"key":[]}]', ], [ // data set #198 - unknown consensus, fallback to Proposal A 'filter_expression_with_value_after_dot_notation_with_wildcard_on_array_of_objects', @@ -1388,7 +1388,7 @@ public static function queryDataProvider(): array 'filter_expression_with_value_from_recursive_descent', '$[?(@..child)]', '[{"key":[{"child":1},{"child":2}]},{"key":[{"child":2}]},{"key":[{}]},{"key":[{"something":42}]},{}' - .']', + . ']', '', ], [ // data set #202 - unknown consensus @@ -1407,15 +1407,15 @@ public static function queryDataProvider(): array 'filter_expression_without_parens', '$[?@.key==42]', '[{"key":0},{"key":42},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"' - .'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' - .'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', + . 'key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"k' + . 'ey":[42]},{"key":{"key":42}},{"key":{"some":42}},{"some":"value"}]', '', ], [ // data set #205 - unknown consensus, fallback to Proposal A 'filter_expression_without_value', '$[?(!@.key)]', '[{"some":"some value"},{"key":true},{"key":false},{"key":null},{"key":"value"},{"key":""},{"key":0}' - .',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', + . ',{"key":1},{"key":-1},{"key":42},{"key":{}},{"key":[]}]', '[{"some":"some value"}]', ], [ // data set #206 - unknown consensus @@ -1506,7 +1506,7 @@ public static function queryDataProvider(): array 'union_with_keys_after_recursive_descent', '$..[\'c\',\'d\']', '[{"c":"cc1","d":"dd1","e":"ee1"},{"c":"cc2","child":{"d":"dd2"}},{"c":"cc3"},{"d":"dd4"},{"child":{' - .'"c":"cc5"}}]', + . '"c":"cc5"}}]', '["cc1","cc2","cc3","cc5","dd1","dd2","dd4"]', ], [ // data set #221