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

SQL2 queries need to quote searches on integer fields with SQLite #206

Open
lsmith77 opened this issue Jul 3, 2014 · 13 comments
Open

SQL2 queries need to quote searches on integer fields with SQLite #206

lsmith77 opened this issue Jul 3, 2014 · 13 comments
Labels

Comments

@lsmith77
Copy link
Member

lsmith77 commented Jul 3, 2014

The following node

$node = $root->addNode('foo');
$node->setProperty('count', 10);

Will not be found with this query:

$sql = "SELECT * FROM [nt:unstructured] WHERE count = 10";
$query = $qm->createQuery($sql, \PHPCR\Query\QueryInterface::JCR_SQL2);

But it will be found with:

$sql = "SELECT * FROM [nt:unstructured] WHERE count = '10'";
$query = $qm->createQuery($sql, \PHPCR\Query\QueryInterface::JCR_SQL2);
@lsmith77 lsmith77 added the bug label Jul 3, 2014
@lsmith77
Copy link
Member Author

lsmith77 commented Jul 3, 2014

Note for Jackrabbit its the other way around.

@dbu
Copy link
Member

dbu commented Jul 7, 2014

so the xpath queries make all numbers strings? maybe we need to build that into our query converter, to but quotes around all literals even when they are numeric. if the semantics of count = 10 is to only find integer fields but not string fields called "count" we would need to do an additional check on the type in the xpath.

@lsmith77
Copy link
Member Author

lsmith77 commented Jul 8, 2014

it seems indeed that the semantics of count = 10 is to find only integer fields. for all other cases one is supposed to use CONTAINS() I guess.

@lsmith77 lsmith77 changed the title SQL2 queries need to quote searches on integer fields SQL2 queries need to quote searches on integer fields with SQLite Jul 15, 2014
@dbu dbu modified the milestone: 1.2 Nov 5, 2014
@dbu
Copy link
Member

dbu commented Jan 5, 2015

@lsmith77 so we close this as well if we give up on #207?

@lsmith77
Copy link
Member Author

lsmith77 commented Jan 5, 2015

no .. imho we can now do this much easier since we have a separate column for the numeric values

@dbu
Copy link
Member

dbu commented Jan 17, 2015

@lsmith77 any chance you could fix this? this is one of the few issues left in milestone 1.2...

@lsmith77
Copy link
Member Author

well I had a fix .. the issue is that I was unable to demonstrate the problem in a test.=

@dbu
Copy link
Member

dbu commented Jan 18, 2015

so, what do we do? drop the issue, postpone it or apply your fix if we can also prove that it does not do any harm?

@wachterjohannes
Copy link
Contributor

@lsmith77 @dbu i have a similar failure in sulu. We query for tags which are saved as an integer array in a property. we can filter (in a sql2 statement where) with tags = 1 or tags = 2. which works very well as long as only one tag is assigned to a page. when we assign two tags (1, 2) on a page and trying to filter for the first tag (1) we get the right result and we are happy ... but when we filter for the second tag (2) then we dont get the page ... when we reverse the assignment and write (2,1) it works for the tag 2 but not for tag 1 ...

i have talked to @dantleech this morning and he said i should place it into apostrophes and everything works fine!

I will test it for jackrabbit but i think it is not a good solution, or is it this?

@lsmith77
Copy link
Member Author

lsmith77 commented Feb 3, 2015

ok .. could be related. if you can manage to come up with a test case, then I am sure we can fix it.

@wachterjohannes
Copy link
Contributor

@dantleech have found the issue and it is not related to this PR ... thanks!

@dbu
Copy link
Member

dbu commented Feb 9, 2015

@lsmith77 do we consider this a blocker for 1.2?

@lsmith77
Copy link
Member Author

lsmith77 commented Feb 9, 2015

no .. I do not consider this a blocker .. at least it has only popped up as an issue in the benchmark. nobody else so far seems to have run into this.

@lsmith77 lsmith77 removed this from the 1.2 milestone Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants