Skip to content

Commit 778fc1c

Browse files
committed
Merge pull request #157 from phpcr/always-escape-propertyname
always quote property name if not already quoted
2 parents 8a5361e + 32aa941 commit 778fc1c

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/PHPCR/Util/QOM/Sql2Generator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function evalFullTextSearchScore($selectorValue = null)
309309
public function evalPropertyValue($propertyName, $selectorName = null)
310310
{
311311
$sql2 = null !== $selectorName ? $this->addBracketsIfNeeded($selectorName) . '.' : '';
312-
if (false !== strpos($propertyName, ':')) {
312+
if ('*' !== $propertyName && substr($propertyName, 0, 1) !== '[') {
313313
$propertyName = "[$propertyName]";
314314
}
315315
$sql2 .= $propertyName;

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,41 @@ public function testDoubleLiteral()
4646

4747
public function testChildNode()
4848
{
49-
$literal = $this->generator->evalChildNode("/foo/bar/baz");
50-
$this->assertSame("ISCHILDNODE(/foo/bar/baz)", $literal);
49+
$literal = $this->generator->evalChildNode('/foo/bar/baz');
50+
$this->assertSame('ISCHILDNODE(/foo/bar/baz)', $literal);
5151
}
5252

5353
public function testDescendantNode()
5454
{
55-
$literal = $this->generator->evalDescendantNode("/foo/bar/baz");
56-
$this->assertSame("ISDESCENDANTNODE(/foo/bar/baz)", $literal);
55+
$literal = $this->generator->evalDescendantNode('/foo/bar/baz');
56+
$this->assertSame('ISDESCENDANTNODE(/foo/bar/baz)', $literal);
5757
}
5858

5959
public function testPopertyExistence()
6060
{
61-
$literal = $this->generator->evalPropertyExistence(null, "foo");
62-
$this->assertSame("foo IS NOT NULL", $literal);
61+
$literal = $this->generator->evalPropertyExistence(null, 'foo');
62+
$this->assertSame('[foo] IS NOT NULL', $literal);
6363
}
6464

6565
public function testFullTextSearch()
6666
{
67-
$literal = $this->generator->evalFullTextSearch("data", "'foo'");
67+
$literal = $this->generator->evalFullTextSearch('data', "'foo'");
6868
$this->assertSame("CONTAINS(data.*, 'foo')", $literal);
69-
$literal = $this->generator->evalFullTextSearch("data", "'foo'", "bar");
70-
$this->assertSame("CONTAINS(data.bar, 'foo')", $literal);
69+
$literal = $this->generator->evalFullTextSearch('data', "'foo'", 'bar');
70+
$this->assertSame("CONTAINS(data.[bar], 'foo')", $literal);
7171
}
7272

7373
public function testColumns()
7474
{
7575
$literal = $this->generator->evalColumns(null);
76-
$this->assertSame("*", $literal);
77-
$literal = $this->generator->evalColumns(array("bar", "foo"));
78-
$this->assertSame("bar, foo", $literal);
76+
$this->assertSame('*', $literal);
77+
$literal = $this->generator->evalColumns(array('bar', 'foo'));
78+
$this->assertSame('bar, foo', $literal);
7979
}
8080

8181
public function testPropertyValue()
8282
{
83-
$literal = $this->generator->evalPropertyValue("foo");
84-
$this->assertSame("foo", $literal);
83+
$literal = $this->generator->evalPropertyValue('foo');
84+
$this->assertSame('[foo]', $literal);
8585
}
8686
}

0 commit comments

Comments
 (0)