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

always quote property name if not already quoted #157

Closed dbu closed 9 years ago

dbu commented 9 years ago

i noticed that a property with hyphens fails otherwise. its valid to put [] around every property, so lets play it safe.

dbu commented 9 years ago

hm, i guess this one we need to look into:

-CONTAINS(data.*, 'foo')
+CONTAINS(data.[*], 'foo')

@dantleech do you know how wildcards and [] interact?

lsmith77 commented 9 years ago

tests need to be updated

dbu commented 9 years ago

tests need to be updated

i will wait for dan to tell whether [*] could be a problem.

dantleech commented 9 years ago

I don't know, but using a wildcard in a name seems to be invalid anyway, at least with the jackrabbit transport:

\PHPCRSH > select * from [nt:unstructured] where CONTAINS(*, "nt:unstructured");
[PHPCR\Query\InvalidQueryException] HTTP 400: '*' not allowed in name
dbu commented 9 years ago

interesting:

> "SELECT * FROM [nt:unstructured] as a WHERE CONTAINS(a.*, 'foobar')"
Results:
> SELECT * FROM [nt:unstructured] as a WHERE CONTAINS(a.[*], 'foobar')
HTTP 400: '*' not allowed in name
> SELECT * FROM [nt:unstructured] as a WHERE CONTAINS(a.a*, 'foobar')
HTTP 400: SELECT * FROM [nt:unstructured] as a WHERE CONTAINS(a.a*(*), 'foobar'); expected: ,
> SELECT * FROM [nt:unstructured] as a WHERE CONTAINS(a.[a*], 'foobar')
HTTP 400: '*' not allowed in name

so it seems you can either say "any" with a wildcard and then there must be no brackets, or you can put the brackets to make sure its taken as a name. is there any other special thing we need to consider, other than *? i think i can then just adapt my PR to check for '*' as a special case.

dbu commented 9 years ago

okay, special case for * added and updated the other tests. lets see

dbu commented 9 years ago

i just ran this with jackalope-jackrabbit and the phpcr-api-tests for the sql2 queries of course are missing a bunch of variations to allow the escaping, but otherwise no error.

if we agree that this is correct, i can do a PR against the api tests to allow the escaping.

dbu commented 9 years ago

this would be green and could be merged, but we would need to update the api tests.

dbu commented 9 years ago

@dantleech do you think this is correct? if so i can adapt the api tests to allow for the escaping.

dantleech commented 9 years ago

My internet is currently awful, but isn't ? a valid wildcard character too? Can we check the spec? Otherwise this is good for me (I guess properties with spaces also don't work currently).

dbu commented 9 years ago

both SELECT a.jcr:mi?in and SELECT a.jcr:mi* lead to parse errors. only a.* is legal, apart from explicit names.