Skip to content

Commit 5850bf0

Browse files
author
Paul King
committed
Adding iregex and notIregex.
1 parent 2987e13 commit 5850bf0

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

lib/node/valueExpression.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ var ValueExpressionMixin = function() {
138138
bitwiseOr : binaryMethod('|'),
139139
bitwiseXor : binaryMethod('#'),
140140
regex : binaryMethod('~'),
141+
iregex : binaryMethod('~*'),
141142
regexp : binaryMethod('REGEXP'),
142143
notRegex : binaryMethod('!~'),
144+
notIregex : binaryMethod('!~*'),
143145
concat : binaryMethod('||'),
144146
key : binaryMethod('->'),
145147
keyText : binaryMethod('->>'),

test/binary-clause-tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ test('operators', function() {
3333
assert.equal(Foo.baz.divide(1).operator, '/');
3434
assert.equal(Foo.baz.modulo(1).operator, '%');
3535
assert.equal(Foo.baz.regex(1).operator, '~');
36+
assert.equal(Foo.baz.iregex(1).operator, '~*');
3637
assert.equal(Foo.baz.notRegex(1).operator, '!~');
38+
assert.equal(Foo.baz.notIregex(1).operator, '!~*');
3739
assert.equal(Foo.baz.regexp(1).operator, 'REGEXP');
3840
assert.equal(Foo.baz.rlike(1).operator, 'RLIKE');
3941
assert.equal(Foo.baz.ilike('asdf').operator, 'ILIKE');

test/dialects/regex-tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ Harness.test({
1313
params: ['age']
1414
});
1515

16+
Harness.test({
17+
query: customer.select(customer.metadata.iregex('age')),
18+
pg: {
19+
text : 'SELECT ("customer"."metadata" ~* $1) FROM "customer"',
20+
string: 'SELECT ("customer"."metadata" ~* \'age\') FROM "customer"'
21+
},
22+
params: ['age']
23+
});
24+
1625
Harness.test({
1726
query: customer.select(customer.metadata.notRegex('age')),
1827
pg: {
@@ -21,3 +30,12 @@ Harness.test({
2130
},
2231
params: ['age']
2332
});
33+
34+
Harness.test({
35+
query: customer.select(customer.metadata.notIregex('age')),
36+
pg: {
37+
text : 'SELECT ("customer"."metadata" !~* $1) FROM "customer"',
38+
string: 'SELECT ("customer"."metadata" !~* \'age\') FROM "customer"'
39+
},
40+
params: ['age']
41+
});

0 commit comments

Comments
 (0)