Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 08f409a

Browse files
authored
more (#267)
1 parent efa6055 commit 08f409a

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

test/cds.ql.test.js

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,10 @@ describe('cds.ql → cqn', () => {
180180
})
181181
})
182182

183-
if (each !== 'SELECT') return
184183

185184
test('with nested inlines', () => {
186185
// SELECT from Foo { *, x, bar.*, car{*}, boo { *, moo.zoo } }
187-
expect(
186+
expect.plain(
188187
SELECT.from (Foo, foo => {
189188
foo.bar `*`,
190189
foo.bar `.*`, //> leading dot indicates inline
@@ -204,6 +203,10 @@ describe('cds.ql → cqn', () => {
204203
})
205204
})
206205

206+
})}
207+
208+
describe ('SELECT where...', ()=>{
209+
207210
it('should correctly handle { ... and:{...} }', () => {
208211
expect(SELECT.from(Foo).where({ x: 1, and: { y: 2, or: { z: 3 } } })).to.eql({
209212
SELECT: {
@@ -245,6 +248,58 @@ describe('cds.ql → cqn', () => {
245248
})
246249
})
247250

251+
test ('where, and, or', ()=>{
252+
expect (
253+
SELECT.from(Foo).where({x:1,and:{y:2}})
254+
).to.eql (
255+
CQL`SELECT from Foo where x=1 and y=2`
256+
) .to.eql ({ SELECT: {
257+
from: {ref:['Foo']},
258+
where: [
259+
{ref:['x']}, '=', {val:1},
260+
'and',
261+
{ref:['y']}, '=', {val:2}
262+
]
263+
}})
264+
265+
expect (
266+
SELECT.from(Foo).where({x:1,or:{y:2}})
267+
).to.eql (
268+
CQL`SELECT from Foo where x=1 or y=2`
269+
).to.eql ({ SELECT: {
270+
from: {ref:['Foo']},
271+
where: [
272+
{ref:['x']}, '=', {val:1},
273+
'or',
274+
{ref:['y']}, '=', {val:2}
275+
]
276+
}})
277+
278+
expect (
279+
SELECT.from(Foo).where({x:1,and:{y:2}}).or({z:3})
280+
).to.eql (
281+
CQL`SELECT from Foo where x=1 and y=2 or z=3`
282+
)
283+
284+
if (cdr) expect (
285+
SELECT.from(Foo).where({x:1}).and({y:2,or:{z:3}})
286+
).to.eql (
287+
CQL`SELECT from Foo where x=1 and ( y=2 or z=3 )`
288+
)
289+
290+
if (cdr) expect (
291+
SELECT.from(Foo).where({1:1}).and({x:1,or:{x:2}}).and({y:2,or:{z:3}})
292+
).to.eql (
293+
CQL`SELECT from Foo where 1=1 and ( x=1 or x=2 ) and ( y=2 or z=3 )`
294+
)
295+
296+
if (cdr) expect (
297+
SELECT.from(Foo).where({x:1,or:{x:2}}).and({y:2,or:{z:3}})
298+
).to.eql (
299+
CQL`SELECT from Foo where ( x=1 or x=2 ) and ( y=2 or z=3 )`
300+
)
301+
})
302+
248303
test('where ( ... cql | {x:y} )', () => {
249304
const args = [`foo`, "'bar'", 3]
250305
const ID = 11
@@ -412,7 +467,6 @@ describe('cds.ql → cqn', () => {
412467

413468
//
414469
})
415-
}
416470

417471
describe(`INSERT...`, () => {
418472
test('entries ({a,b}, ...)', () => {

0 commit comments

Comments
 (0)