Skip to content

Commit c3636a2

Browse files
committed
Fix issue when generating tests/data/lexer/lexUtf8.out
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent 73c97ac commit c3636a2

File tree

244 files changed

+1470
-646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+1470
-646
lines changed

src/Tools/TestGenerator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\SqlParser\Exceptions\ParserException;
1111
use PhpMyAdmin\SqlParser\Lexer;
1212
use PhpMyAdmin\SqlParser\Parser;
13+
use PhpMyAdmin\SqlParser\UtfString;
1314
use Zumba\JsonSerializer\JsonSerializer;
1415

1516
use function file_exists;
@@ -25,6 +26,7 @@
2526
use function sprintf;
2627
use function str_contains;
2728
use function str_ends_with;
29+
use function str_replace;
2830
use function strpos;
2931
use function substr;
3032

@@ -170,6 +172,16 @@ public static function build($type, $input, $output, $debug = null, $ansi = fals
170172
$serializer = new JsonSerializer();
171173
// Writing test's data.
172174
$encoded = $serializer->serialize($test);
175+
176+
/**
177+
* Can not decode null char in keys.
178+
*
179+
* @see UtfString::$asciiMap
180+
*/
181+
if (str_contains($encoded, '"asciiMap":{"\u0000":0,"')) {
182+
$encoded = str_replace('"asciiMap":{"\u0000":0,"', '"asciiMap":{"', $encoded);
183+
}
184+
173185
$encoded = json_encode(
174186
json_decode($encoded),
175187
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION

tests/data/bugs/gh14.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@
609609
"OR": 1,
610610
"XOR": 1,
611611
"NOT": 1,
612-
"MOD": 1
612+
"MOD": 1,
613+
"OVER": 2
613614
},
614615
"database": null,
615616
"table": "actor",
@@ -770,7 +771,8 @@
770771
"OR": 1,
771772
"XOR": 1,
772773
"NOT": 1,
773-
"MOD": 1
774+
"MOD": 1,
775+
"OVER": 2
774776
},
775777
"database": null,
776778
"table": null,

tests/data/bugs/gh16.out

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,8 @@
17661766
"OR": 1,
17671767
"XOR": 1,
17681768
"NOT": 1,
1769-
"MOD": 1
1769+
"MOD": 1,
1770+
"OVER": 2
17701771
},
17711772
"database": null,
17721773
"table": "jos_core_acl_aro",
@@ -2005,7 +2006,8 @@
20052006
"OR": 1,
20062007
"XOR": 1,
20072008
"NOT": 1,
2008-
"MOD": 1
2009+
"MOD": 1,
2010+
"OVER": 2
20092011
},
20102012
"database": null,
20112013
"table": null,
@@ -2132,7 +2134,8 @@
21322134
"OR": 1,
21332135
"XOR": 1,
21342136
"NOT": 1,
2135-
"MOD": 1
2137+
"MOD": 1,
2138+
"OVER": 2
21362139
},
21372140
"database": null,
21382141
"table": null,
@@ -2259,7 +2262,8 @@
22592262
"OR": 1,
22602263
"XOR": 1,
22612264
"NOT": 1,
2262-
"MOD": 1
2265+
"MOD": 1,
2266+
"OVER": 2
22632267
},
22642268
"database": null,
22652269
"table": null,
@@ -2386,7 +2390,8 @@
23862390
"OR": 1,
23872391
"XOR": 1,
23882392
"NOT": 1,
2389-
"MOD": 1
2393+
"MOD": 1,
2394+
"OVER": 2
23902395
},
23912396
"database": null,
23922397
"table": null,
@@ -2513,7 +2518,8 @@
25132518
"OR": 1,
25142519
"XOR": 1,
25152520
"NOT": 1,
2516-
"MOD": 1
2521+
"MOD": 1,
2522+
"OVER": 2
25172523
},
25182524
"database": null,
25192525
"table": null,
@@ -2886,6 +2892,7 @@
28862892
"options": null
28872893
}
28882894
],
2895+
"with": null,
28892896
"select": null,
28902897
"like": null,
28912898
"partitionBy": null,

tests/data/bugs/gh317.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@
501501
"OR": 1,
502502
"XOR": 1,
503503
"NOT": 1,
504-
"MOD": 1
504+
"MOD": 1,
505+
"OVER": 2
505506
},
506507
"database": null,
507508
"table": "demo",
@@ -663,7 +664,8 @@
663664
"OR": 1,
664665
"XOR": 1,
665666
"NOT": 1,
666-
"MOD": 1
667+
"MOD": 1,
668+
"OVER": 2
667669
},
668670
"database": null,
669671
"table": null,

tests/data/bugs/gh9.out

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,8 @@
11711171
"OR": 1,
11721172
"XOR": 1,
11731173
"NOT": 1,
1174-
"MOD": 1
1174+
"MOD": 1,
1175+
"OVER": 2
11751176
},
11761177
"database": null,
11771178
"table": null,
@@ -1196,7 +1197,8 @@
11961197
"OR": 1,
11971198
"XOR": 1,
11981199
"NOT": 1,
1199-
"MOD": 1
1200+
"MOD": 1,
1201+
"OVER": 2
12001202
},
12011203
"database": null,
12021204
"table": "foo",
@@ -1389,7 +1391,8 @@
13891391
"OR": 1,
13901392
"XOR": 1,
13911393
"NOT": 1,
1392-
"MOD": 1
1394+
"MOD": 1,
1395+
"OVER": 2
13931396
},
13941397
"database": null,
13951398
"table": null,
@@ -1414,7 +1417,8 @@
14141417
"OR": 1,
14151418
"XOR": 1,
14161419
"NOT": 1,
1417-
"MOD": 1
1420+
"MOD": 1,
1421+
"OVER": 2
14181422
},
14191423
"database": null,
14201424
"table": "foo",
@@ -1675,7 +1679,8 @@
16751679
"OR": 1,
16761680
"XOR": 1,
16771681
"NOT": 1,
1678-
"MOD": 1
1682+
"MOD": 1,
1683+
"OVER": 2
16791684
},
16801685
"database": null,
16811686
"table": "tb",
@@ -1790,6 +1795,7 @@
17901795
}
17911796
}
17921797
],
1798+
"with": null,
17931799
"select": null,
17941800
"like": null,
17951801
"partitionBy": null,

tests/data/bugs/pma11800.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@
577577
"OR": 1,
578578
"XOR": 1,
579579
"NOT": 1,
580-
"MOD": 1
580+
"MOD": 1,
581+
"OVER": 2
581582
},
582583
"database": null,
583584
"table": null,

tests/data/bugs/pma11836.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,8 @@
901901
"OR": 1,
902902
"XOR": 1,
903903
"NOT": 1,
904-
"MOD": 1
904+
"MOD": 1,
905+
"OVER": 2
905906
},
906907
"database": null,
907908
"table": null,
@@ -926,7 +927,8 @@
926927
"OR": 1,
927928
"XOR": 1,
928929
"NOT": 1,
929-
"MOD": 1
930+
"MOD": 1,
931+
"OVER": 2
930932
},
931933
"database": null,
932934
"table": "alumnos",

tests/data/bugs/pma11843.out

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,8 @@
866866
"OR": 1,
867867
"XOR": 1,
868868
"NOT": 1,
869-
"MOD": 1
869+
"MOD": 1,
870+
"OVER": 2
870871
},
871872
"database": null,
872873
"table": "mytable",
@@ -1092,7 +1093,8 @@
10921093
"OR": 1,
10931094
"XOR": 1,
10941095
"NOT": 1,
1095-
"MOD": 1
1096+
"MOD": 1,
1097+
"OVER": 2
10961098
},
10971099
"database": null,
10981100
"table": null,
@@ -1108,6 +1110,7 @@
11081110
}
11091111
}
11101112
],
1113+
"with": null,
11111114
"select": null,
11121115
"like": null,
11131116
"partitionBy": null,

tests/data/bugs/pma11879.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,8 @@
868868
"OR": 1,
869869
"XOR": 1,
870870
"NOT": 1,
871-
"MOD": 1
871+
"MOD": 1,
872+
"OVER": 2
872873
},
873874
"database": null,
874875
"table": "tbproject",
@@ -917,6 +918,7 @@
917918
],
918919
"set": null,
919920
"select": null,
921+
"with": null,
920922
"onDuplicateSet": null,
921923
"CLAUSES": [],
922924
"END_OPTIONS": [],

tests/data/lexer/lexUtf8.out

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,114 @@
2121
"byteIdx": 19,
2222
"charIdx": 18,
2323
"byteLen": 20,
24-
"charLen": 19
24+
"charLen": 19,
25+
"asciiMap": {
26+
"\t": 9,
27+
"\n": 10,
28+
"\u000b": 11,
29+
"\f": 12,
30+
"\r": 13,
31+
" ": 32,
32+
"!": 33,
33+
"\"": 34,
34+
"#": 35,
35+
"$": 36,
36+
"%": 37,
37+
"&": 38,
38+
"'": 39,
39+
"(": 40,
40+
")": 41,
41+
"*": 42,
42+
"+": 43,
43+
",": 44,
44+
"-": 45,
45+
".": 46,
46+
"\/": 47,
47+
"0": 48,
48+
"1": 49,
49+
"2": 50,
50+
"3": 51,
51+
"4": 52,
52+
"5": 53,
53+
"6": 54,
54+
"7": 55,
55+
"8": 56,
56+
"9": 57,
57+
":": 58,
58+
";": 59,
59+
"<": 60,
60+
"=": 61,
61+
">": 62,
62+
"?": 63,
63+
"@": 64,
64+
"A": 65,
65+
"B": 66,
66+
"C": 67,
67+
"D": 68,
68+
"E": 69,
69+
"F": 70,
70+
"G": 71,
71+
"H": 72,
72+
"I": 73,
73+
"J": 74,
74+
"K": 75,
75+
"L": 76,
76+
"M": 77,
77+
"N": 78,
78+
"O": 79,
79+
"P": 80,
80+
"Q": 81,
81+
"R": 82,
82+
"S": 83,
83+
"T": 84,
84+
"U": 85,
85+
"V": 86,
86+
"W": 87,
87+
"X": 88,
88+
"Y": 89,
89+
"Z": 90,
90+
"[": 91,
91+
"\\": 92,
92+
"]": 93,
93+
"^": 94,
94+
"_": 95,
95+
"`": 96,
96+
"a": 97,
97+
"b": 98,
98+
"c": 99,
99+
"d": 100,
100+
"e": 101,
101+
"f": 102,
102+
"g": 103,
103+
"h": 104,
104+
"i": 105,
105+
"j": 106,
106+
"k": 107,
107+
"l": 108,
108+
"m": 109,
109+
"n": 110,
110+
"o": 111,
111+
"p": 112,
112+
"q": 113,
113+
"r": 114,
114+
"s": 115,
115+
"t": 116,
116+
"u": 117,
117+
"v": 118,
118+
"w": 119,
119+
"x": 120,
120+
"y": 121,
121+
"z": 122,
122+
"{": 123,
123+
"|": 124,
124+
"}": 125,
125+
"~": 126,
126+
"": 127,
127+
"Ã": 195,
128+
"@utf8encoded": {
129+
"Ã": 1
130+
}
131+
}
25132
},
26133
"len": 19,
27134
"last": 19,

0 commit comments

Comments
 (0)