Skip to content

Commit

Permalink
fix(vercel): LIKE query typo
Browse files Browse the repository at this point in the history
  • Loading branch information
lizheming committed Mar 6, 2021
1 parent ba5aac8 commit 090230c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/server/src/service/storage/cloudbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ module.exports = class extends Base {
break;
case 'LIKE':
const first = where[k][1][0];
const last = where[k][1][-1];
const last = where[k][1].slice(-1);
let reg;
if(first === '%' && last === '%') {
reg = new RegExp(where[k][1].slice(1, -1));
} else if(first === '%') {
reg = new RegExp(where[k][1].slice(1, -1) + '$');
reg = new RegExp(where[k][1].slice(1) + '$');
} else if(last === '%') {
reg = new RegExp('^' + where[k][1].slice(1, -1));
reg = new RegExp('^' + where[k][1].slice(0, -1));
}
filter[parseKey(k)] = reg;
break;
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/service/storage/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ module.exports = class extends Base {
break;
case 'LIKE':
const first = where[k][1][0];
const last = where[k][1][-1];
const last = where[k][1].slice(-1);
let reg;
if(first === '%' && last === '%') {
reg = new RegExp(where[k][1].slice(1, -1));
} else if(first === '%') {
reg = new RegExp(where[k][1].slice(1, -1) + '$');
reg = new RegExp(where[k][1].slice(1) + '$');
} else if(last === '%') {
reg = new RegExp('^' + where[k][1].slice(1, -1));
reg = new RegExp('^' + where[k][1].slice(0, -1));
}
filters.push(item => reg.test(item[k]));
break;
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/service/storage/leancloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ module.exports = class extends Base {
break;
case 'LIKE':
const first = where[k][1][0];
const last = where[k][1][-1];
const last = where[k][1].slice(-1);
if(first === '%' && last === '%') {
instance.contains(k, where[k][1].slice(1, -1));
} else if(first === '%') {
instance.endsWidth(k, where[k][1].slice(1));
instance.endsWith(k, where[k][1].slice(1));
} else if(last === '%') {
instance.startsWidth(k, where[k][1].slice(-1));
instance.startsWith(k, where[k][1].slice(0, -1));
}
break;
case '!=':
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/service/storage/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ module.exports = class extends Base {
break;
case 'LIKE':
const first = where[k][1][0];
const last = where[k][1][-1];
const last = where[k][1].slice(-1);
if(first === '%' && last === '%') {
instance.where({
[parseKey(k)]: { $regex: new RegExp(where[k][1].slice(1, -1)) }
});
} else if(first === '%') {
instance.where({
[parseKey(k)]: { $regex: new RegExp(where[k][1].slice(1, -1) + '$') }
[parseKey(k)]: { $regex: new RegExp(where[k][1].slice(1) + '$') }
});
} else if(last === '%') {
instance.where({
[parseKey(k)]: { $regex: new RegExp('^' + where[k][1].slice(1, -1)) }
[parseKey(k)]: { $regex: new RegExp('^' + where[k][1].slice(0, -1)) }
});
}
break;
Expand Down

0 comments on commit 090230c

Please sign in to comment.