Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix precedence parenthesis #140

Merged
merged 2 commits into from
Nov 11, 2014
Merged

Fix precedence parenthesis #140

merged 2 commits into from
Nov 11, 2014

Conversation

dantleech
Copy link
Member

Broken since: phpcr/phpcr-utils#128

@dantleech
Copy link
Member Author

We shouldn't really have these tests here - they apply to phpcr-utils not the implementation.

I think we should have some separate package which can provide things like the QOM factory so that this stuff can be tested where it is. Maybe we could split the jackalope QOM code into a separate package?

@lsmith77
Copy link
Member

well phpcr utils is not mandatory for PHPCR implementations

@dantleech
Copy link
Member Author

Yeah. So we should move these tests to phpcr-utils then I guess:

use PHPCR\Util\QOM\Sql2Generator;
use PHPCR\Util\QOM\Sql2ToQomQueryConverter;
use PHPCR\Util\QOM\QomToSql2QueryConverter;
use PHPCR\Util\ValueConverter;

We could use Jackalope FS to bootstrap the QOM maybe.

@@ -59,7 +59,7 @@ public static function getQueries()

$queries['6.7.12.Constraint.Precedence.3'] = array(
'SELECT * FROM [nt:file] AS file WHERE NOT file.prop1 = \'1\' OR file.prop2 = \'2\' AND NOT file.prop3 = \'3\'',
'SELECT * FROM [nt:file] AS file WHERE (NOT file.prop1 = \'1\' OR (file.prop2 = \'2\' AND NOT file.prop3 = \'3\'))',
'SELECT * FROM [nt:file] AS file WHERE ((NOT file.prop1 = \'1\') OR (file.prop2 = \'2\' AND (NOT file.prop3 = \'3\')))',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the line above is correct, so we should not change it here. or add an additional one if you want.

@dbu
Copy link
Member

dbu commented Oct 20, 2014

We shouldn't really have these tests here - they apply to phpcr-utils not the implementation.

the problem is that the parser and everything depend on a qom factory which is in the implementation. i think the original idea is that having the test here confirms that a particular implementation works correctly with the parser and query builder.

but indeed its a bit annoying. lets do like this: move tests into phpcr-utils and add jackalope-doctrine-dbal as require-dev there. but keep all jackalope specific things in one bootstrap bit that can be replaced, should another phpcr implementation want to use the tests to check their query functionality.

@dbu
Copy link
Member

dbu commented Oct 24, 2014

i think https://travis-ci.org/jackalope/jackalope-jackrabbit/builds/37575242 is related to this.

can you just add the lines as additional lines instead of replacing? assuming they are all valid and equivalent, just adding parenthesis to state the obvious :-)

@dantleech
Copy link
Member Author

Updated, I have added the variations instead of replacing them.

With regards to moving the tests to PHPCR-Utils - I am a bit confused - if we move the Parser tests to phpcr-utils, what do we need to keep here?

$queries['6.7.15.Not'] = 'SELECT * FROM [nt:file] AS file WHERE NOT file.prop1 IS NOT NULL';
$queries['6.7.15.Not'] = array(
'SELECT * FROM [nt:file] AS file WHERE NOT file.prop1 IS NOT NULL',
'SELECT * FROM [nt:file] AS file WHERE (NOT file.prop1 IS NOT NULL)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the most parenthesis not need to do WHERE (NOT (file.prop1 IS NOT NULL))? what if i negate a combined expression like NOT(a OR b)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantleech wdyt? is there more to fix or is that case already handled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. Are you implying that the logic is broken and it should be doing what you suggest, or that we should add an additional variation to cover if it is ever handled differently?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was wondering whether your fix is complete or there are more things to fix for the NOT case. how does the query builder distinguish NOT(a OR b) from (NOT a) OR b? afaik NOT a OR b precedence would make it (NOT a) or b.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but this is about the test not the code?. We should probably create an issue on phpcr-utils

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbu added a commit that referenced this pull request Nov 11, 2014
@dbu dbu merged commit f1a0b4c into master Nov 11, 2014
@dbu dbu deleted the fix-precedence-parenthesis branch November 11, 2014 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants