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

This should fix Criteria startsWith and endsWith #6397

Closed

Conversation

svycka
Copy link
Contributor

@svycka svycka commented Apr 13, 2017

using like this:

$criteria = Criteria::create();
//$criteria->andWhere(Criteria::expr()->contains("appName", 'a'));
$criteria->andWhere(Criteria::expr()->startsWith("group", 'doct'));
$repository->matching($criteria);
# before
SELECT ... FROM app_data t0 WHERE t0.`group`
# after
SELECT ... FROM app_data t0 WHERE t0.`group` LIKE ?

and exception if more than one expression:

An exception occurred while executing 'SELECT ... FROM app_data t0 WHERE (t0.appName LIKE ? AND t0.group )' with params ["%a%", "doct"]:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

@svycka
Copy link
Contributor Author

svycka commented Apr 13, 2017

not sure why tests failing. Maybe travis caching issue?

@lcobucci
Copy link
Member

@svycka that's just weird but I restarted the job, let's wait and see 😉

@lcobucci
Copy link
Member

@svycka I just cloned you branch and ran the tests after running composer update --prefer-lowest and the test suite is broken, can you please investigate the reason?

@svycka
Copy link
Contributor Author

svycka commented Apr 13, 2017

@lcobucci found the reason its because startsWith and endsWwith were introduced in doctrine/collection:1.4.0 doctrine/collections#78 hmm not sure what to do :) require ^1.4 :D

@lcobucci
Copy link
Member

@svycka feel free to bump up the dependency

@lcobucci lcobucci self-assigned this Apr 13, 2017
@lcobucci lcobucci added this to the 2.6.0 milestone Apr 13, 2017
@lcobucci
Copy link
Member

lcobucci commented Apr 13, 2017

@svycka I labelled it as New Feature since it adds support for the new ExpressionBuilder methods, I'll get it reviewed ASAP.

Thanks for you collaboration 😉

@lcobucci lcobucci added this to Review in ORM v2.6.x Apr 13, 2017
Copy link
Contributor

@phansys phansys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status: Needs work.

$repository = $this->_em->getRepository(CmsUser::class);

$users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'Foo')));
$this->assertEquals(0, count($users));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use assertCount() instead.

@lcobucci
Copy link
Member

@svycka manually merged on a557c97 thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants