mirror of
https://github.com/knex/knex.git
synced 2025-06-26 22:00:25 +00:00
Co-authored-by: Raz Luvaton <16746759+rluvaton@users.noreply.github.com>
This commit is contained in:
parent
aedba5e49c
commit
9659a20753
@ -329,6 +329,13 @@ class QueryCompiler_SQLite3 extends QueryCompiler {
|
||||
onJsonPathEquals(clause) {
|
||||
return this._onJsonPathEquals('json_extract', clause);
|
||||
}
|
||||
|
||||
whereILike(statement) {
|
||||
return `${this._columnClause(statement)} ${this._not(
|
||||
statement,
|
||||
'like '
|
||||
)}${this._valueClause(statement)}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QueryCompiler_SQLite3;
|
||||
|
@ -556,7 +556,14 @@ describe('Where', function () {
|
||||
|
||||
describe('where like', async function () {
|
||||
beforeEach(function () {
|
||||
if (!(isPostgreSQL(knex) || isMssql(knex) || isMysql(knex))) {
|
||||
if (
|
||||
!(
|
||||
isPostgreSQL(knex) ||
|
||||
isSQLite(knex) ||
|
||||
isMssql(knex) ||
|
||||
isMysql(knex)
|
||||
)
|
||||
) {
|
||||
return this.skip();
|
||||
}
|
||||
});
|
||||
@ -630,10 +637,23 @@ describe('Where', function () {
|
||||
expect(result[7].email).to.equal('test8@example.com');
|
||||
});
|
||||
|
||||
it("doesn't find data using whereLike when different case sensitivity", async () => {
|
||||
it("doesn't find data using whereLike when different case sensitivity", async function () {
|
||||
const result = await knex('accounts').whereLike('email', 'Test1%');
|
||||
// sqlite only supports case-insensitive search
|
||||
if (isSQLite(knex)) {
|
||||
this.skip();
|
||||
}
|
||||
expect(result).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it('supports only case-insensitive searches in sqlite', async function () {
|
||||
const result = await knex('accounts').whereILike('email', 'Test1%');
|
||||
if (!isSQLite(knex)) {
|
||||
this.skip();
|
||||
}
|
||||
expect(result.length).to.equal(1);
|
||||
expect(result[0].email).to.equal('test1@example.com');
|
||||
});
|
||||
});
|
||||
|
||||
it('Retains array bindings, #228', function () {
|
||||
|
@ -879,6 +879,10 @@ describe('QueryBuilder', () => {
|
||||
sql: 'select * from [users] where [name] collate SQL_Latin1_General_CP1_CI_AS like ?',
|
||||
bindings: ['luk%'],
|
||||
},
|
||||
sqlite3: {
|
||||
sql: 'select * from `users` where `name` like ?',
|
||||
bindings: ['luk%'],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -903,6 +907,10 @@ describe('QueryBuilder', () => {
|
||||
sql: 'select * from [users] where [name] collate SQL_Latin1_General_CP1_CS_AS like ? and [name] collate SQL_Latin1_General_CP1_CS_AS like ? or [name] collate SQL_Latin1_General_CP1_CS_AS like ?',
|
||||
bindings: ['luk1%', 'luk2%', 'luk3%'],
|
||||
},
|
||||
sqlite3: {
|
||||
sql: 'select * from `users` where `name` like ? and `name` like ? or `name` like ?',
|
||||
bindings: ['luk1%', 'luk2%', 'luk3%'],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -928,6 +936,10 @@ describe('QueryBuilder', () => {
|
||||
sql: 'select * from [users] where [name] collate SQL_Latin1_General_CP1_CI_AS like ? and [name] collate SQL_Latin1_General_CP1_CI_AS like ? or [name] collate SQL_Latin1_General_CP1_CI_AS like ?',
|
||||
bindings: ['luk1%', 'luk2%', 'luk3%'],
|
||||
},
|
||||
sqlite3: {
|
||||
sql: 'select * from `users` where `name` like ? and `name` like ? or `name` like ?',
|
||||
bindings: ['luk1%', 'luk2%', 'luk3%'],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user