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

Query returns no results on indexed column if query string is longer than index #198

Open
flack opened this issue Mar 29, 2013 · 4 comments
Assignees
Milestone

Comments

@flack
Copy link
Member

flack commented Mar 29, 2013

I have the following code:

// email is a string field with index="yes"
$email = 'thisisareallyreallylongstringtomakesurewerelongerthantheindex@unitteststheproblemshowedupwith86chrs.fx';
$person = new openpsa_person;
$person->email = $email;
$person->create();

$qb = new midgard_query_builder('openpsa_person');
$qb->add_constraint('email', '=', $email);
$results = $qb->execute();
echo count($results); // Expected: 1, Actual: 0

what is interesting is that if you use this constraint instead:

$qb->add_constraint('email', 'LIKE', $email);

then it works as expected. I also tried a plain mysql select with "=", and it works, too, so this is something that midgard does

piotras added a commit to piotras/midgard-core that referenced this issue Apr 2, 2013
piotras added a commit to piotras/midgard-core that referenced this issue Apr 2, 2013
@ghost ghost assigned piotras Apr 2, 2013
@piotras
Copy link
Member

piotras commented Apr 2, 2013

@flack Please, use QuerySelect instead of QB. The latter is no longer supported and depreciated.

@flack
Copy link
Member Author

flack commented Apr 2, 2013

@piotras: Well, I would like to, but a quick grep for query_builder in the openpsa code base shows 1383 matches, so it would take a whole team of people to change all that in any reasonable timeframe. Plus, I still have to be backwards compatible to midgard1, since that is where all my production code is running (and migrating all that can easily take another year or so).

The only thing that might be feasible is to write some emulation layer that offers query builder api to components, but uses QS internally, but I couldn't say if this is a) at all possible and b) what kind of weird side effects it may have on the aforementioned 1383 callers.

@piotras
Copy link
Member

piotras commented Apr 2, 2013

@flack I think I did something similar in python some time ago. I could try to write the same in PHP. The only one problem might be "nested" orders.

@flack
Copy link
Member Author

flack commented Apr 2, 2013

@piotras: That would be great. If there was something that basically works, I could integrate it into midcom and then use it as QB backend when running on mgd2. I briefly thought about trying to write something like this myself, but the prospect of figuring out things like $qb->add_constraint(topic.metadata.creator, '=', $user->id); put me off. I mean, ok, theroretically it should be possible to figure out the correct behavior using reflection, but it seems like a big hassle and also not very good for performance.
Also AFAICT, constraint groups (AND/OR) work very differently, so I wonder how much effort that would take. BTW: Is there any API documentation on QS a lowly PHP developer like me can read? I looked at http://midgard-project.org/docs/api/core/gjallarhorn/MidgardQuerySelect.html, but all that does is giving me a headache :-)

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

No branches or pull requests

2 participants