Skip to content

Fixed parser so that square brackets count as delimiters #121

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

Merged
merged 1 commit into from
Oct 8, 2014

Conversation

dantleech
Copy link
Member

This is an "enabling" improvement which allows me to use the parser to parse things like:

UPDATE [foo] SET foo = ['foo','bar',baz'];

Square brackets are delimiters in JCR-SQL2 (right?) so I think this is valid without compromise.

$token = substr($token, 1, -1);
if ($token === '[') {
$token = $this->scanner->fetchNextToken();
$endDelimiter = $this->scanner->fetchNextToken();
Copy link
Member Author

Choose a reason for hiding this comment

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

This should simply be $this->scanner->expectToken(']');

Copy link
Member

Choose a reason for hiding this comment

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

+1

@dbu
Copy link
Member

dbu commented Aug 28, 2014

yeah, [] are used for indexes and are not legal in a node name. however, i am not entirely sure if this change could lead to some regression somewhere in jackalope, when we assume that /foo[3]/bar[2] would work. then again, jackalope officially does not support same name siblings yet.

is using square brakets for index in multivalue lists something ever used by jcr sql2? i think not, as you don't care about position in a multivalue.

@lsmith77
Copy link
Member

tests seem to be flaky on HHVM .. some of the tests sometimes fail with a 1 second timeout

@dantleech dantleech force-pushed the square_brackets_are_delimiters branch from 7f7d830 to 389396b Compare August 31, 2014 18:59
@lsmith77
Copy link
Member

lsmith77 commented Sep 2, 2014

as you might be aware Oak does not support SNS and there is a discussion about how to deal with people importing content with SNS, so they are discussing how to deal with square brackets in node names. maybe this discussions will give some hints:
http://www.mail-archive.com/oak-dev@jackrabbit.apache.org/msg06825.html

@dantleech
Copy link
Member Author

So just to clarify - does this change (using square brackets in an UPDATE in PHPCR-Shell) conflict with SNS?

I guess it shouldn't, i.e. SNS square brackets are only used on paths, whereas the UPDATE square brackets are only used on properties.

I guess in any case it shouldn't be hard to support SNS notation with this change.

@lsmith77
Copy link
Member

lsmith77 commented Sep 3, 2014

the concern is just that this change MIGHT break parsing of SNS paths inside queries.

ie. for example WHERE ISDESCENDANTNODE('/foo[2]')

@dbu
Copy link
Member

dbu commented Sep 3, 2014

As we only ever update properties and never whole nodes i think Dan is right.

----- Reply message -----
Von: "dantleech" notifications@github.com
An: "phpcr/phpcr-utils" phpcr-utils@noreply.github.com
Cc: "David Buchmann" david@liip.ch
Betreff: [phpcr-utils] Fixed parser so that square brackets count as delimiters (#121)
Datum: Mi., Sep. 3, 2014 04:50
So just to clarify - does this change (using square brackets in an UPDATE in PHPCR-Shell) conflict with SNS?

I guess it shouldn't, i.e. SNS square brackets are only used on paths, whereas the UPDATE square brackets are only used on properties.

I guess in any case it shouldn't be hard to support SNS notation with this change.


Reply to this email directly or view it on GitHub.

@dantleech
Copy link
Member Author

Are we OK to merge this?

@dbu
Copy link
Member

dbu commented Oct 8, 2014

lets merge. ok @lsmith77 ?

lsmith77 added a commit that referenced this pull request Oct 8, 2014
Fixed parser so that square brackets count as delimiters
@lsmith77 lsmith77 merged commit 4b8d3d9 into master Oct 8, 2014
@dbu
Copy link
Member

dbu commented Oct 9, 2014

i think this breaks jackalope: https://travis-ci.org/jackalope/jackalope-jackrabbit/jobs/37503114

@dbu dbu deleted the square_brackets_are_delimiters branch October 9, 2014 19:53
@dantleech
Copy link
Member Author

ok, I wasn't aware that there were tests for these classes in the API tests.

The other problems are "ok" - they make sense and I guess just need to be updated, but this one is odd:

PHPCR\Query\InvalidQueryException: Syntax error: Expected ')', found '/home' in SELECT * FROM [nt:file] AS file INNER JOIN [nt:folder] AS folder ON ISSAMENODE(file, folder, [/home])

Caused by this:

        $queries['6.7.9.SameNodeJoinCondition.Path_Space'] = array(
            'SELECT * FROM [nt:file] AS file INNER JOIN [nt:folder] AS folder ON ISSAMENODE(file, folder, ["/home node"])',
            'SELECT * FROM [nt:file] AS file INNER JOIN [nt:folder] AS folder ON ISSAMENODE(file, folder, [/home node])',
        );

Why are there square brackets there? Is the spec suggesting that the square brackets are part of the grammer, or simply that it is an optional thing?

But we can revert first and ask questions later if needs be :)

@dbu
Copy link
Member

dbu commented Oct 10, 2014

as long as we don't tag a release lets see if we can clear this up without reverting. created #131

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