Skip to content

Commit

Permalink
Merge pull request #3282 from strapi/fix/search
Browse files Browse the repository at this point in the history
Fix invalid filter name and cleanup some search query
  • Loading branch information
lauriejim committed May 17, 2019
2 parents f536517 + cfe28bc commit b439a75
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/strapi/lib/core-api/queries/bookshelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ module.exports = ({ model }) => {
qb.orderBy(filters.sort.key, filters.sort.order);
}

if (filters.skip) {
qb.offset(_.toNumber(filters.skip));
if (filters.start) {
qb.offset(_.toNumber(filters.start));
}

if (filters.limit) {
Expand Down Expand Up @@ -173,13 +173,13 @@ const buildSearchQuery = (qb, model, params) => {

if (!_.isNaN(_.toNumber(query))) {
searchInt.forEach(attribute => {
qb.orWhereRaw(`${attribute} = ${_.toNumber(query)}`);
qb.orWhereRaw(attribute, _.toNumber(query));
});
}

if (query === 'true' || query === 'false') {
searchBool.forEach(attribute => {
qb.orWhereRaw(`${attribute} = ${_.toNumber(query === 'true')}`);
qb.orWhereRaw(attribute, _.toNumber(query === 'true'));
});
}

Expand Down

0 comments on commit b439a75

Please sign in to comment.