Skip to content

Commit 016de59

Browse files
committed
fix(Query) where equal INT out of range
1 parent b90b990 commit 016de59

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adonis-search",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Mail provider for adonis framework and has support for all common mailing services to send emails",
55
"main": "index.js",
66
"directories": {

src/Query/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Database = use('Database')
77
class Query {
88
static get INT () { return 1 }
99
static get STRING () { return 2 }
10+
static get INT_MAX_VALUE () { return 2147483647 }
1011

1112
/**
1213
* @param {Object} request
@@ -80,7 +81,8 @@ class Query {
8081
}
8182

8283
const whereLike = (column) => {
83-
builder.orWhere(Database.raw(`LOWER(${column})`), 'LIKE', Database.raw(`LOWER('%${this._query.search}%')`))
84+
const search = this._query.search.toLowerCase()
85+
builder.orWhere(Database.raw(`LOWER(${column})`), 'LIKE', `%${search}%`)
8486
}
8587

8688
const whereEqual = (column) => {
@@ -93,7 +95,7 @@ class Query {
9395
} else {
9496
if (column === this.constructor.INT) {
9597
const valueInt = Number.parseInt(this._query.search)
96-
if (Number.isInteger(valueInt)) {
98+
if (Number.isInteger(valueInt) && valueInt <= this.constructor.INT_MAX_VALUE) {
9799
whereEqual(i)
98100
}
99101
} else {

0 commit comments

Comments
 (0)