File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed
tests/PHPCR/Tests/Util/QOM Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ 1.5.2
5+ -----
6+
7+ * Fix SQL 2 scanner delimiter detection to handle that tokens don't necessarily have whitespace between them.
8+
491.5.1
510-----
611
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ protected function scan($sql2)
171171 $ regexpTokens [] = preg_quote ($ token , '/ ' );
172172 }
173173
174- $ regexp = '/^ ' .implode ('([ \t\n]+ ) ' , $ regexpTokens ).'$/ ' ;
174+ $ regexp = '/^ ' .implode ('([ \t\n]* ) ' , $ regexpTokens ).'$/ ' ;
175175 preg_match ($ regexp , $ sql2 , $ this ->delimiters );
176176 $ this ->delimiters [0 ] = '' ;
177177
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PHPCR \Tests \Util \QOM ;
4+
5+ use PHPCR \Util \QOM \Sql2Scanner ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ class Sql2ScannerTest extends TestCase
9+ {
10+ public function testToken ()
11+ {
12+ $ scanner = new Sql2Scanner ('SELECT page.* FROM [nt:unstructured] AS page ' );
13+ $ expected = [
14+ 'SELECT ' ,
15+ 'page ' ,
16+ '. ' ,
17+ '* ' ,
18+ 'FROM ' ,
19+ '[nt:unstructured] ' ,
20+ 'AS ' ,
21+ 'page ' ,
22+ ];
23+
24+ while ($ token = $ scanner ->fetchNextToken ()) {
25+ $ this ->assertEquals (array_shift ($ expected ), $ token );
26+ }
27+ }
28+
29+ public function testDelimiter ()
30+ {
31+ $ scanner = new Sql2Scanner ('SELECT page.* FROM [nt:unstructured] AS page ' );
32+ $ expected = [
33+ '' ,
34+ ' ' ,
35+ '' ,
36+ '' ,
37+ ' ' ,
38+ ' ' ,
39+ ' ' ,
40+ ' ' ,
41+ ];
42+
43+ while ($ token = $ scanner ->fetchNextToken ()) {
44+ $ this ->assertEquals (array_shift ($ expected ), $ scanner ->getPreviousDelimiter ());
45+ }
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments