Index: lib/Doctrine/Query/Tokenizer.php =================================================================== --- lib/Doctrine/Query/Tokenizer.php (revision 7285) +++ lib/Doctrine/Query/Tokenizer.php (working copy) @@ -298,7 +298,11 @@ * @return string */ private function getSplitRegExpFromArray(array $d){ - $d = array_map('preg_quote', $d); + foreach ($d as $key => $string) { + $escapedString = preg_quote($string); + if (preg_match('#^\w+$#', $string)) $escapedString = "\W$escapedString\W"; + $d[$key] = $escapedString; + } if (in_array(' ', $d)) { $d[] = '\s'; Index: tests/TokenizerTestCase.php =================================================================== --- tests/TokenizerTestCase.php (revision 7285) +++ tests/TokenizerTestCase.php (working copy) @@ -125,6 +125,16 @@ $str = 'foo.field and bar.field'; $a = $tokenizer->bracketExplode($str, array(' \&\& ', ' AND '), '(', ')'); $this->assertEqual($a, array('foo.field', 'bar.field')); + + // test the JOIN splitter as used in Doctrine_Query_From::parse() + $str = 'foo.field join bar.field'; + $a = $tokenizer->bracketExplode($str, 'JOIN'); + $this->assertEqual($a, array('foo.field', 'bar.field')); + + // test that table names including the split string are unaffected + $str = 'foojointable.field join bar.field'; + $a = $tokenizer->bracketExplode($str, 'JOIN'); + $this->assertEqual($a, array('foojointable.field', 'bar.field')); }