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

Fixed a couple of issues in query plugin. #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Spudley
Copy link

@Spudley Spudley commented Mar 26, 2014

Two issues found while implementing a site using this plugin:

  1. interpolate was crashing on the last part[i] iteration because parts array is often one element larger than args array.

Fixed by adding graceful handling for undefined args[i].

  1. In my tests, args.length was never equal to 1, so the callback function was never being called. This was trying test that the last argument was a callback, but wasn't working.

Fixed by changing the test to look at the last arg and check directly that it is a function. The callback is now called as expected.

These fixes allowed me to write queries like this:

db.where('this.rec.address1.match(/?/i) || this.rec.address2.match(/?/i)',searchFor,searchFor,function(recs) {
    $.each(recs, function(i,rec) {
        console.log(rec);
    });
});

Previously the query plug-in only worked if the query string ended with a ? placeholder.

Two issues found while implementing a site using this plugin:

1. interpolate was crashing on the last part[i] iteration because parts array is often one element larger than args array.

Fixed by adding graceful handling for undefined args[i].

2. In my tests, args.length was never equal to 1, so the callback function was never being called. This was trying test that the last argument was a callback, but wasn't working.

Fixed by changing the test to look at the last arg and check directly that it is a function. The callback is now called as expected.


These fixes allowed me to write queries like this:

    db.where('this.rec.address1.match(/?/i) || this.rec.address2.match(/?/i)',searchFor,searchFor,function(recs) {
        $.each(recs, function(i,rec) {
            console.log(rec);
        });
    });

Previously the query plug-in only worked if the query string ended with a ? placeholder.
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

Successfully merging this pull request may close these issues.

1 participant