Skip to content

Commit 75deb4d

Browse files
authored
Merge pull request #109 from FoolCode/b-empty-match-query
add check to only add non-empty compiled match queries
2 parents 734f74d + 49c5bd0 commit 75deb4d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/SphinxQL.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ public function compileMatch()
460460
$pre .= $this->escapeMatch($match['value']);
461461
}
462462

463-
$matched[] = '('.$pre.')';
463+
if ($pre !== '') {
464+
$matched[] = '('.$pre.')';
465+
}
464466
}
465467

466468
$matched = implode(' ', $matched);

tests/SphinxQL/SphinxQLTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,14 @@ public function testMatch()
532532
->getStored();
533533

534534
$this->assertCount(2, $result);
535+
536+
$result = SphinxQL::create(self::$conn)->select()
537+
->from('rt')
538+
->match('')
539+
->compile()
540+
->getCompiled();
541+
542+
$this->assertEquals('SELECT * FROM rt WHERE MATCH(\'\')', $result);
535543
}
536544

537545
public function testEscapeMatch()

0 commit comments

Comments
 (0)