phpcr / phpcr-utils

A set of helper classes and command line commands you want to use with phpcr, but that are not part of the API itself
phpcr.github.io
Other
72 stars 30 forks source link

[WIP] Add parenthesis to the output of SQL2 #16

Closed chregu closed 12 years ago

chregu commented 12 years ago

Add parenthesis around OR and AND constraints. Not all are necessary but better than none.

See #12 for the details

WIP = Work in progress, don't merge it yet :)

chregu commented 12 years ago

Bleh, now of course phpcr-api-tests are failing.

There were 3 failures:

1) PHPCR\Tests\Query\QOM\ConvertQueriesBackAndForthTest::testBackAndForth
SQL2-->QOM: Original query = SELECT * FROM [nt:file] WHERE sel1.prop1 IS NOT NULL AND sel2.prop2 IS NOT NULL
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'SELECT * FROM [nt:file] WHERE sel1.prop1 IS NOT NULL AND sel2.prop2 IS NOT NULL'
+'SELECT * FROM [nt:file] WHERE (sel1.prop1 IS NOT NULL AND sel2.prop2 IS NOT NULL)'

/opt/git/jackalope-jackrabbit/vendor/phpcr/phpcr-api-tests/tests/06_Query/QOM/ConvertQueriesBackAndForthTest.php:48
/usr/local/php5-20120203-085139/bin/phpunit:46

2) PHPCR\Tests\Query\QOM\QomToSql2ConverterTest::testAndConstraint
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'SELECT * FROM [nt:file] WHERE sel1.prop1 IS NOT NULL AND sel2.prop2 IS NOT NULL'
+'SELECT * FROM [nt:file] WHERE (sel1.prop1 IS NOT NULL AND sel2.prop2 IS NOT NULL)'

/opt/git/jackalope-jackrabbit/vendor/phpcr/phpcr-api-tests/tests/06_Query/QOM/QomToSql2ConverterTest.php:376
/opt/git/jackalope-jackrabbit/vendor/phpcr/phpcr-api-tests/tests/06_Query/QOM/QomToSql2ConverterTest.php:127
/usr/local/php5-20120203-085139/bin/phpunit:46

3) PHPCR\Tests\Query\QOM\QomToSql2ConverterTest::testOrConstraint
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'SELECT * FROM [nt:file] WHERE sel1.prop1 IS NOT NULL OR sel2.prop2 IS NOT NULL'
+'SELECT * FROM [nt:file] WHERE (sel1.prop1 IS NOT NULL OR sel2.prop2 IS NOT NULL)'

/opt/git/jackalope-jackrabbit/vendor/phpcr/phpcr-api-tests/tests/06_Query/QOM/QomToSql2ConverterTest.php:376
/opt/git/jackalope-jackrabbit/vendor/phpcr/phpcr-api-tests/tests/06_Query/QOM/QomToSql2ConverterTest.php:138
/usr/local/php5-20120203-085139/bin/phpunit:46

Not that easy. Java solves it with looking at the parent constraint, maybe that's another approach