File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
tests/PHPCR/Tests/Util/QOM Expand file tree Collapse file tree 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)
188188 } elseif (!$ stringStartCharacter ) {
189189 // If there is no start character already we have found the beginning of a new string
190190 $ 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+ }
191197 }
192198 }
193199 $ isEscaped = $ character === '\\' ;
Original file line number Diff line number Diff line change @@ -124,6 +124,41 @@ public function testSQLEscapedStrings2()
124124 $ this ->expectTokensFromScanner ($ scanner , $ expected );
125125 }
126126
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+
127162 public function testThrowingErrorOnUnclosedString ()
128163 {
129164 $ this ->expectException (InvalidQueryException::class);
You can’t perform that action at this time.
0 commit comments