Skip to content

Commit 8320659

Browse files
committed
Merge pull request #128 from phpcr/not_fix
Fixed parenthesis for NOT constraint
2 parents cdb41ce + 4b92eda commit 8320659

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/PHPCR/Util/QOM/BaseSqlGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function evalOr($constraint1, $constraint2)
8383
*/
8484
public function evalNot($constraint)
8585
{
86-
return "NOT $constraint";
86+
return "(NOT $constraint)";
8787
}
8888

8989
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace PHPCR\Tests\Util\QOM;
4+
5+
use PHPCR\Util\QOM\Sql1Generator;
6+
use PHPCR\Util\ValueConverter;
7+
8+
abstract class BaseSqlGeneratorTest extends \PHPUnit_Framework_TestCase
9+
{
10+
public function testNot()
11+
{
12+
$string = $this->generator->evalNot("foo = bar");
13+
$this->assertSame("(NOT foo = bar)", $string);
14+
}
15+
}

tests/PHPCR/Tests/Util/QOM/Sql2GeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PHPCR\Util\QOM\Sql2Generator;
66
use PHPCR\Util\ValueConverter;
77

8-
class Sql2GeneratorTest extends \PHPUnit_Framework_TestCase
8+
class Sql2GeneratorTest extends BaseSqlGeneratorTest
99
{
1010
protected $generator;
1111

0 commit comments

Comments
 (0)