Skip to content

Add ILIKE functionality #194

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

Merged
merged 4 commits into from
Mar 2, 2017
Merged

Conversation

alireza-ahmadi
Copy link
Contributor

Description

Loopback-datasource-juggler added support for ILIKE and NOT ILIKE functionality in v3.1.0, but the PostgreSQL connector does not update to support them. This pull request adds this functionality by adding a few lines to lib/postgresql.js file.

Related issues

Please let me if any other changes needed.

@slnode
Copy link

slnode commented Dec 15, 2016

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode
Copy link

slnode commented Dec 15, 2016

Can one of the admins verify this patch?

2 similar comments
@slnode
Copy link

slnode commented Dec 15, 2016

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Dec 15, 2016

Can one of the admins verify this patch?

@superkhau
Copy link
Contributor

Can you add some tests to verify your changes and prevent regressions in the future?

@alireza-ahmadi
Copy link
Contributor Author

Yes, I will add a few test in the next few days.

@zbarbuto
Copy link
Contributor

@alireza-ahmadi any news on this?

@alireza-ahmadi
Copy link
Contributor Author

@zbarbuto @superkhau I have added a few tests for the added feature. Also because I couldn't find the required test for LIKE and NOT LIKE operators, I have added a few tests for them as well because I thought that all of these operators are pattern matching operators and are linked.

Please let me know if the tests don't have a good coverage or any other changes needed.

Copy link
Contributor

@superkhau superkhau left a comment

Choose a reason for hiding this comment

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

Overall LGTM, a few minor nits to fix and we can land this. ;)

function(done) {
Post.find({where: {content: {like: '%TestCase%'}}},
function(err, posts) {
should.not.exists(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

if (err) return done(err); for better stack traces

Post.destroyAll(done);
});

it('should support case sensitive queries using like',
Copy link
Contributor

Choose a reason for hiding this comment

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

it('supports case sensi...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I see the other tests are different (we need to eventually update all of them to this style over time

});
});

it('should not support case insensitive queries using like',
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

function(done) {
Post.find({where: {content: {like: '%tesTcasE%'}}},
function(err, posts) {
should.not.exists(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

});
});

it('should support like for no match', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

it('should support ilike for no match', function(done) {
Post.find({where: {content: {ilike: '%tesTxasE%'}}},
function(err, posts) {
should.not.exists(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

});
});

it('should support negative case insensitive queries using nilike',
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

function(done) {
Post.find({where: {content: {nilike: '%casE%'}}},
function(err, posts) {
should.not.exist(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

});
});

it('should support nilike for no match', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

it('should support nilike for no match', function(done) {
Post.find({where: {content: {nilike: '%tesTxasE%'}}},
function(err, posts) {
should.not.exists(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@alireza-ahmadi
Copy link
Contributor Author

@superkhau Thanks for the review, I have applied the requested changes. Please let me know if any other changes required.

@superkhau
Copy link
Contributor

@slnode test please

@alireza-ahmadi alireza-ahmadi force-pushed the feature/ilike branch 2 times, most recently from 0db8b34 to 91c7a05 Compare February 22, 2017 21:42
});
after(function deleteTestFixtures(done) {
Post.destroyAll(done);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the after since we delete in the before already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@superkhau Thanks for the review. I will apply these changes, rebase, and push the changes in the next few minutes.

title: 't2',
content: 'T2_TheOtherCase',
}], done);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

You can move the two functions to the bottom of the context block:

before(deleteTestFixtures);
before(createTestFixtures);

it('...');
it('...');
...

function deleteTestFixtures(done) {
  Post.destroyAll(done);
}
function create...

http://loopback.io//doc/en/contrib/style-guide.html#layout-of-test-files

@superkhau superkhau requested review from kjdelisle and removed request for kjdelisle February 28, 2017 21:44
@superkhau superkhau self-requested a review February 28, 2017 21:44
Copy link
Contributor

@superkhau superkhau left a comment

Choose a reason for hiding this comment

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

Approved with my last suggested fixed.

@superkhau
Copy link
Contributor

@kjdelisle Reassigning to your squad.

@alireza-ahmadi alireza-ahmadi force-pushed the feature/ilike branch 2 times, most recently from eb6489a to c9bade4 Compare February 28, 2017 22:14
- Change test descriptions to match the new style
- Change error handling mechanism for better stack traces
@alireza-ahmadi
Copy link
Contributor Author

I have applied the requested code style changes(and a typo in createTestFixtures) and rebased to the last state of master branch. Again, please let me know if any other changes required.

@superkhau
Copy link
Contributor

superkhau commented Feb 28, 2017

Let's wait for CI to pass, should be good to land. TY for the contribution BTW. 🙇‍♂️

@zbarbuto
Copy link
Contributor

Thanks for your effort @alireza-ahmadi

@superkhau Can we expect a new point release soon with this feature?

@superkhau
Copy link
Contributor

@zbarbuto Can be released as soon as it lands. @kjdelisle will help you there once it passes CI -- I think it's hanging ATM now though. ;(

@kjdelisle
Copy link
Contributor

@slnode test please

@kjdelisle
Copy link
Contributor

LGTM

@kjdelisle kjdelisle merged commit ff2dff0 into loopbackio:master Mar 2, 2017
@kjdelisle kjdelisle removed the review label Mar 2, 2017
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 this pull request may close these issues.

8 participants