File tree 2 files changed +41
-0
lines changed
tests/PHPCR/Tests/Util/QOM
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,12 @@ protected function scan($sql2)
188
188
} elseif (!$ stringStartCharacter ) {
189
189
// If there is no start character already we have found the beginning of a new string
190
190
$ stringStartCharacter = $ character ;
191
+
192
+ // When tokenizing `AS"abc"` add the current token (AS) as token already
193
+ if (strlen ($ currentToken ) > 1 ) {
194
+ $ tokens [] = substr ($ currentToken , 0 , strlen ($ currentToken ) - 1 );
195
+ $ currentToken = $ character ;
196
+ }
191
197
}
192
198
}
193
199
$ isEscaped = $ character === '\\' ;
Original file line number Diff line number Diff line change @@ -124,6 +124,41 @@ public function testSQLEscapedStrings2()
124
124
$ this ->expectTokensFromScanner ($ scanner , $ expected );
125
125
}
126
126
127
+ public function testSquareBrakets ()
128
+ {
129
+ $ sql = 'WHERE ISSAMENODE(file, ["/home node"]) ' ;
130
+
131
+ $ scanner = new Sql2Scanner ($ sql );
132
+ $ expected = [
133
+ 'WHERE ' ,
134
+ 'ISSAMENODE ' ,
135
+ '( ' ,
136
+ 'file ' ,
137
+ ', ' ,
138
+ '[ ' ,
139
+ '"/home node" ' ,
140
+ '] ' ,
141
+ ') ' ,
142
+ ];
143
+
144
+ $ this ->expectTokensFromScanner ($ scanner , $ expected );
145
+ }
146
+
147
+ public function testTokenizingWithMissingSpaces ()
148
+ {
149
+ $ sql = 'SELECT * AS"all" ' ;
150
+
151
+ $ scanner = new Sql2Scanner ($ sql );
152
+ $ expected = [
153
+ 'SELECT ' ,
154
+ '* ' ,
155
+ 'AS ' ,
156
+ '"all" ' ,
157
+ ];
158
+
159
+ $ this ->expectTokensFromScanner ($ scanner , $ expected );
160
+ }
161
+
127
162
public function testThrowingErrorOnUnclosedString ()
128
163
{
129
164
$ this ->expectException (InvalidQueryException::class);
You can’t perform that action at this time.
0 commit comments