make expression(a, b) resolve to a = b
This commit is contained in:
Родитель
24bdee55a9
Коммит
651897762e
|
@ -56,6 +56,10 @@ var Expression = function(field, op, value)
|
|||
} else {
|
||||
left = `${escape(field, true)}`;
|
||||
}
|
||||
if(value === undefined) {
|
||||
value = op;
|
||||
op = 'eq';
|
||||
}
|
||||
if(value instanceof Expression) {
|
||||
right = `(${value.toString()})`;
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,10 @@ describe('expression tests', function() {
|
|||
expect(new Expression(e2, '=', e3).toString()).toEqual('(b add 2) eq (5)');
|
||||
});
|
||||
|
||||
it('should express e2 = e3, method 2', function() {
|
||||
expect(new Expression(e2, e3).toString()).toEqual('(b add 2) eq (5)');
|
||||
});
|
||||
|
||||
it('should express e2 != e3', function() {
|
||||
expect(new Expression(e2, '!=', e3).toString()).toEqual('(b add 2) ne (5)');
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('filter tests', function() {
|
|||
});
|
||||
|
||||
it('should produce a filter credit > 5000 and (balance = 0 or status = \'stop\')', function() {
|
||||
expect(odata.filter('credit', '>', 5000).and(Odata.expression('balance', '=', 0).or('status', '=', 'stop')).query())
|
||||
expect(odata.filter('credit', '>', 5000).and(Odata.expression('balance', 0).or('status', 'stop')).query())
|
||||
.toEqual('https://example.com/Customer?%24filter=(credit%20gt%205000)%20and%20((balance%20eq%200)' +
|
||||
'%20or%20(status%20eq%20\'stop\'))');
|
||||
});
|
||||
|
@ -45,7 +45,7 @@ describe('filter tests', function() {
|
|||
});
|
||||
|
||||
it('should produce a filter \'ABC001\' eq account', function() {
|
||||
expect(odata.filter(Odata.literal('ABC001'), '=', Odata.identifier('account')).query())
|
||||
expect(odata.filter(Odata.literal('ABC001'), Odata.identifier('account')).query())
|
||||
.toEqual('https://example.com/Customer?%24filter=\'ABC001\'%20eq%20account');
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче