mirror of
https://github.com/knex/knex.git
synced 2026-01-06 03:57:29 +00:00
Fix #344, case insensitive operators
This commit is contained in:
parent
1a438e3d41
commit
920d1ef16e
@ -97,7 +97,7 @@ Formatter.prototype.columnize = function(target) {
|
||||
Formatter.prototype.operator = function(value) {
|
||||
var raw;
|
||||
if (raw = this.checkRaw(value)) return raw;
|
||||
if (!_.contains(this.operators, value)) {
|
||||
if (!_.contains(this.operators, (value || '').toLowerCase())) {
|
||||
throw new TypeError('The operator "' + value + '" is not permitted');
|
||||
}
|
||||
return value;
|
||||
|
||||
@ -650,6 +650,11 @@ module.exports = function(pgclient, mysqlclient, sqlite3client) {
|
||||
expect(q2.toSQL().sql).to.equal('insert into "recipients" (recipient_id, email) select \'user\', \'user@foo.com\' where not exists (select 1 from "recipients" where "recipient_id" = ?)');
|
||||
});
|
||||
|
||||
it('supports capitalized operators', function() {
|
||||
var str = sql().select('*').from('users').where('name', 'LIKE', '%test%').toString();
|
||||
expect(str).to.equal('select * from "users" where "name" LIKE \'%test%\'');
|
||||
});
|
||||
|
||||
it('throws if you try to use an invalid operator', function() {
|
||||
var err;
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user