|
|
@ -6,7 +6,7 @@ require('simple-mocha'); |
|
|
|
|
|
|
|
|
|
|
|
var conditions= [ |
|
|
|
/* -----------Tests for and conditoins---------- */ |
|
|
|
/* -----------Tests for and conditions---------- */ |
|
|
|
{ |
|
|
|
name: 'handle simple and conditions', |
|
|
|
input:{ f1: 10, f2: 20, f3: 30 }, |
|
|
@ -42,6 +42,11 @@ var conditions= [ |
|
|
|
input:{ f1: ['IN', [10,50]], f2: [ '<', 20 ], f3: 30 }, |
|
|
|
output: 'select * where ("f1" in (10, 50) and "f2" < 20 and "f3" = 30)' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'handle basic operators :: notin', |
|
|
|
input:{ f1: ['NOTIN', [10,50]], f2: [ '<', 20 ], f3: 30 }, |
|
|
|
output: 'select * where ("f1" not in (10, 50) and "f2" < 20 and "f3" = 30)' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'handle multiple conditions in one field', |
|
|
|
input:{ f1: [ [ 'LIKE', 20 ], 21, [ 'AND_BETWEEN', [ 40, 45 ] ] ], f2: 20, f3: 30 }, |
|
|
@ -62,7 +67,12 @@ var conditions= [ |
|
|
|
input:{ f1: ['IN', [ 50, 60 ] ], f2: 20, f3: 30 }, |
|
|
|
output: 'select * where ("f1" in (50, 60) and "f2" = 20 and "f3" = 30)' |
|
|
|
}, |
|
|
|
/* -----------Tests for or conditoins---------- */ |
|
|
|
{ |
|
|
|
name: 'handle simple and condition with not in statement', |
|
|
|
input:{ f1: ['NOTIN', [ 50, 60 ] ], f2: 20, f3: 30 }, |
|
|
|
output: 'select * where ("f1" not in (50, 60) and "f2" = 20 and "f3" = 30)' |
|
|
|
}, |
|
|
|
/* -----------Tests for or conditions---------- */ |
|
|
|
{ |
|
|
|
name: 'handle simple or condition', |
|
|
|
input:[ { f1: 10 }, { f2: 20 }, { f3: 30 } ], |
|
|
@ -103,11 +113,21 @@ var conditions= [ |
|
|
|
input:[ { f1: ['IN',[ 50, 60 ]] }, { f2: 20 }, { f3: 30 } ], |
|
|
|
output: 'select * where (("f1" in (50, 60)) or ("f2" = 20) or ("f3" = 30))' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'handle simple or condition with not in statement', |
|
|
|
input:[ { f1: ['NOTIN',[ 50, 60 ]] }, { f2: 20 }, { f3: 30 } ], |
|
|
|
output: 'select * where (("f1" not in (50, 60)) or ("f2" = 20) or ("f3" = 30))' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'handle simple or condition with in statement :MongoQuery', |
|
|
|
input:[ { f1: {$in:[ 50, 60 ]} }, { f2: 20 }, { f3: 30 } ], |
|
|
|
output: 'select * where (("f1" in (50, 60)) or ("f2" = 20) or ("f3" = 30))' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'handle simple or condition with nin statement :MongoQuery', |
|
|
|
input:[ { f1: {$nin:[ 50, 60 ]} }, { f2: 20 }, { f3: 30 } ], |
|
|
|
output: 'select * where (("f1" not in (50, 60)) or ("f2" = 20) or ("f3" = 30))' |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|