Fix #344, case insensitive operators

This commit is contained in:
Tim Griesser 2014-06-30 12:42:33 -04:00
parent 1a438e3d41
commit 920d1ef16e
2 changed files with 6 additions and 1 deletions

View File

@ -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;

View File

@ -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 {