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

Commit f583766

Browse files
committed
Prep for cleaning up cds.ql
1 parent 839048d commit f583766

File tree

1 file changed

+48
-32
lines changed

1 file changed

+48
-32
lines changed

test/cds.ql.test.js

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const CQL = ([cql]) => cds.parse.cql(cql)
44
const Foo = { name: 'Foo' }
55
const Books = { name: 'capire.bookshop.Books' }
66

7-
const { parse:cdr } = cds.ql
7+
const { cdr } = cds.ql
88

99
// while jest has 'test' as alias to 'it', mocha doesn't
1010
if (!global.test) global.test = it
@@ -111,7 +111,7 @@ describe('cds.ql → cqn', () => {
111111
.to.eql(SELECT.from(Foo).columns('*'))
112112
.to.eql(SELECT.from(Foo).columns((foo) => foo('*')))
113113
.to.eql({
114-
SELECT: { from: { ref: ['Foo'] }, columns: [cdr ? '*' : { ref: ['*'] }] },
114+
SELECT: { from: { ref: ['Foo'] }, columns: [{ ref: ['*'] }] },
115115
})
116116

117117
if (cdr) expect(parsed).to.eql(fluid)
@@ -162,7 +162,7 @@ describe('cds.ql → cqn', () => {
162162
.to.eql({
163163
SELECT: {
164164
from: { ref: ['Foo'] },
165-
columns: [{ ref: ['a'] }, { ref: ['b'] }, cdr ? '*' : { ref: ['*'] }],
165+
columns: [{ ref: ['a'] }, { ref: ['b'] }, { ref: ['*'] }],
166166
},
167167
})
168168
})
@@ -182,7 +182,7 @@ describe('cds.ql → cqn', () => {
182182
SELECT: {
183183
from: { ref: ['Foo'] },
184184
columns: [
185-
cdr ? '*' : { ref: ['*'] },
185+
{ ref: ['*'] },
186186
{ ref: ['x'] },
187187
{ ref: ['car'], expand: ['*'] },
188188
{
@@ -246,19 +246,37 @@ describe('cds.ql → cqn', () => {
246246
expect(SELECT.from(Foo).where({ x: 1, and: { y: 2, or: { z: 3 } } })).to.eql({
247247
SELECT: {
248248
from: { ref: ['Foo'] },
249-
where: [
249+
where: cdr ? [
250250
{ ref: ['x'] },
251251
'=',
252252
{ val: 1 },
253253
'and',
254-
'(',
255-
{ ref: ['y'] },
256-
'=',
257-
{ val: 2 },
258-
'or',
259-
{ ref: ['z'] },
254+
// '(',
255+
{xpr:[
256+
{ ref: ['y'] },
257+
'=',
258+
{ val: 2 },
259+
'or',
260+
{ ref: ['z'] },
261+
'=',
262+
{ val: 3 },
263+
]},
264+
// ')',
265+
] : [
266+
{ ref: ['x'] },
260267
'=',
261-
{ val: 3 },
268+
{ val: 1 },
269+
'and',
270+
'(',
271+
// {xpr:[
272+
{ ref: ['y'] },
273+
'=',
274+
{ val: 2 },
275+
'or',
276+
{ ref: ['z'] },
277+
'=',
278+
{ val: 3 },
279+
// ]},
262280
')',
263281
],
264282
},
@@ -280,9 +298,8 @@ describe('cds.ql → cqn', () => {
280298
).to.eql({
281299
SELECT: {
282300
from: { ref: ['Foo'] },
283-
where: cds.version >= '5.3.0'
301+
where: cdr
284302
? [
285-
// '(', //> this one is not required
286303
{ ref: ['ID'] },
287304
'=',
288305
{ val: ID },
@@ -291,18 +308,17 @@ describe('cds.ql → cqn', () => {
291308
'in',
292309
{ list: args.map(val => ({ val })) },
293310
'and',
294-
'(', //> this one is missing, and that's changing the logic -> that's a BUG
295-
{ ref: ['x'] },
296-
'like',
297-
{ val: '%x%' },
298-
'or',
299-
{ ref: ['y'] },
300-
'>=',
301-
{ val: 9 },
302-
')',
311+
{xpr:[
312+
{ ref: ['x'] },
313+
'like',
314+
{ val: '%x%' },
315+
'or',
316+
{ ref: ['y'] },
317+
'>=',
318+
{ val: 9 },
319+
]},
303320
]
304321
: [
305-
// '(', //> this one is not required
306322
{ ref: ['ID'] },
307323
'=',
308324
{ val: ID },
@@ -311,14 +327,14 @@ describe('cds.ql → cqn', () => {
311327
'in',
312328
{ val: args },
313329
'and',
314-
'(', //> this one is missing, and that's changing the logic -> that's a BUG
315-
{ ref: ['x'] },
316-
'like',
317-
{ val: '%x%' },
318-
'or',
319-
{ ref: ['y'] },
320-
'>=',
321-
{ val: 9 },
330+
'(',
331+
{ ref: ['x'] },
332+
'like',
333+
{ val: '%x%' },
334+
'or',
335+
{ ref: ['y'] },
336+
'>=',
337+
{ val: 9 },
322338
')',
323339
],
324340
},

0 commit comments

Comments
 (0)