-
Notifications
You must be signed in to change notification settings - Fork 21
Date querying #120
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
Date querying #120
Conversation
does it matter when using the QOM if i use a date string or an actual date object? |
can we wrap this up too? |
we have methods in BaseCase to compare dates: https://github.com/phpcr/phpcr-api-tests/blob/master/inc/BaseCase.php#L246 and also assertSimilarDateTime added in #125 - could that help? |
Not really sure how this works. ..
That is not so trivial. We just have two QOM object graphs to compare. What we would need to do is then somewhere store an optional path for where we might have date strings that need to be compared differently. Now the question is, doesn't it make sense to convert things that look like a date to a date instance? imho if you use a string representation (ie. SQL2) then you simply subject yourself to this kind of unclarity .. ie. did the person just use a string or was it meant to be a date? But I think it makes sense to assume they meant a date. Alternatively we could also do the following change which would then mean in the QOM we use a string rather than a date. To me this highlights that it makes sense to do a string to date conversion in the parser instead:
|
maybe the parser would need to understand the CAST syntax to create dates, and we would move closer to how what jackrabbit works. in jackrabbit, writing a date string will not match with a date property. |
hmm yeah I guess CAST could clarify this, though its technically not necessary to always write explicit CAST calls into SQL when working with Jackrabbit for example. btw we also already automatically convert integers/floats as well as booleans. so to me converting dates is consistent. |
the spec says this: http://www.day.com/specs/jcr/2.0/6_Query.html#6.7.34%20Literal An UncastLiteral may be interpreted as a Value of property type STRING or some other type inferred from static analysis. A CastLiteral, on the other hand, is interpreted as the string form of a Value of the PropertyType indicated. so the parser could try to guess if something is a date, but we should probably only match the YYYY-mm-dd format and the jcr timestamp and nothing else. and i added a TODO on phpcr-utils about the cast parsing. should actually be not that difficult to do phpcr/phpcr-utils#98 |
we match on |
thanks! |
supersedes #95
requires phpcr/phpcr-utils#99