Added few cds.ql tests (#402)
This commit is contained in:
@@ -411,18 +411,69 @@ describe('cds.ql → cqn', () => {
|
|||||||
]
|
]
|
||||||
}})
|
}})
|
||||||
|
|
||||||
expect (
|
const ql_with_groups_fix = !!cds.ql.Query.prototype.flat
|
||||||
SELECT.from(Foo).where({x:1,or:{y:2}})
|
if (ql_with_groups_fix) {
|
||||||
).to.eql (
|
|
||||||
CQL`SELECT from Foo where x=1 or y=2`
|
expect (
|
||||||
).to.eql ({ SELECT: {
|
SELECT.from(Foo).where({x:1}).or({y:2}).and({z:3})
|
||||||
from: {ref:['Foo']},
|
).to.eql ({ SELECT: {
|
||||||
where: [
|
from: {ref:['Foo']},
|
||||||
{ref:['x']}, '=', {val:1},
|
where: [
|
||||||
'or',
|
{ref:['x']}, '=', {val:1},
|
||||||
{ref:['y']}, '=', {val:2}
|
'or',
|
||||||
]
|
{ref:['y']}, '=', {val:2},
|
||||||
}})
|
'and',
|
||||||
|
{ref:['z']}, '=', {val:3},
|
||||||
|
]
|
||||||
|
}})
|
||||||
|
|
||||||
|
expect (
|
||||||
|
SELECT.from(Foo).where({x:1,or:{y:2}}).and({z:3})
|
||||||
|
).to.eql ({ SELECT: {
|
||||||
|
from: {ref:['Foo']},
|
||||||
|
where: [
|
||||||
|
{xpr:[
|
||||||
|
{ref:['x']}, '=', {val:1},
|
||||||
|
'or',
|
||||||
|
{ref:['y']}, '=', {val:2},
|
||||||
|
]},
|
||||||
|
'and',
|
||||||
|
{ref:['z']}, '=', {val:3},
|
||||||
|
]
|
||||||
|
}})
|
||||||
|
|
||||||
|
expect (
|
||||||
|
SELECT.from(Foo).where({a:1}).or({x:1,or:{y:2}}).and({z:3})
|
||||||
|
).to.eql ({ SELECT: {
|
||||||
|
from: {ref:['Foo']},
|
||||||
|
where: [
|
||||||
|
{ref:['a']}, '=', {val:1},
|
||||||
|
'or',
|
||||||
|
{xpr:[
|
||||||
|
{ref:['x']}, '=', {val:1},
|
||||||
|
'or',
|
||||||
|
{ref:['y']}, '=', {val:2},
|
||||||
|
]},
|
||||||
|
'and',
|
||||||
|
{ref:['z']}, '=', {val:3},
|
||||||
|
]
|
||||||
|
}})
|
||||||
|
|
||||||
|
expect (
|
||||||
|
SELECT.from(Foo).where({x:1,or:{y:2}})
|
||||||
|
).to.eql ({ SELECT: {
|
||||||
|
from: {ref:['Foo']},
|
||||||
|
where: [
|
||||||
|
{xpr:[
|
||||||
|
{ref:['x']}, '=', {val:1},
|
||||||
|
'or',
|
||||||
|
{ref:['y']}, '=', {val:2},
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
}})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
expect (
|
expect (
|
||||||
SELECT.from(Foo).where({x:1,and:{y:2}}).or({z:3})
|
SELECT.from(Foo).where({x:1,and:{y:2}}).or({z:3})
|
||||||
|
|||||||
Reference in New Issue
Block a user