-
Notifications
You must be signed in to change notification settings - Fork 21
Added test for LENGTH operand #123
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,4 +316,46 @@ public function testQueryMultiValuedProperty() | |
$this->assertSame('foo bar', $rows->current()->getValue('tags')); | ||
} | ||
|
||
public function testQueryWithLengthOperand() | ||
{ | ||
/** @var $query QueryInterface */ | ||
$query = $this->sharedFixture['qm']->createQuery(' | ||
SELECT data.* | ||
FROM [nt:unstructured] AS data | ||
WHERE LENGTH(data.jcr:data) = 121 | ||
AND ISDESCENDANTNODE([/tests_general_base]) | ||
', | ||
QueryInterface::JCR_SQL2 | ||
); | ||
|
||
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query); | ||
$result = $query->execute(); | ||
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result); | ||
|
||
$rows = $result->getRows(); | ||
|
||
$this->assertCount(3, $rows, 'Expected 3 nodes with a jcr:data property with length 121'); | ||
|
||
/** @var $query QueryInterface */ | ||
$query = $this->sharedFixture['qm']->createQuery(' | ||
SELECT data.* | ||
FROM [nt:unstructured] AS data | ||
WHERE | ||
data.empty-value IS NOT NULL | ||
AND LENGTH(data.empty-value) < 1 | ||
AND LENGTH(data.empty-value) > -1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is a very complicated way of expressing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the idea was to test =, < and >. But might be better to test those in seperate queries. The jcr:data is a binary property, will pull it out and put it in a separate test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (y) excellent! |
||
AND ISDESCENDANTNODE([/tests_general_base]) | ||
', | ||
QueryInterface::JCR_SQL2 | ||
); | ||
|
||
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query); | ||
$result = $query->execute(); | ||
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result); | ||
|
||
$rows = $result->getRows(); | ||
|
||
$this->assertCount(1, $rows, 'Expected 1 node with property "empty-value" with a length smaller then 1 and greater then -1'); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you create this namespace for? i don't see it used anywhere.
indeed this will cause major pain with jackrabbit, as namespaces are global and we use the phpcr namespace already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it because it caused an error about a invalid XML while I was testing this. But figured that the namespace isn't needed in the general JCR XML. Only in the XML used by jackalope doctrine dbal.
Removed it.