cancel
Showing results for 
Search instead for 
Did you mean: 

CDS 6 and usage of IN operator with string literals

nicorunge
Participant
0 Kudos
350

Hi all,

the june notes for cds 6 included the following:

"Legacy CQN syntax for representation of values for IN operator

  • where: [..., 'IN', { val: [1,2,3] }] isn’t supported anymore → use:
  • where: [..., 'IN', { list: [{val:1},{val:2},{val:3}] }] instead"

In my application I'm using string literals and noticed the following behavior after the update to cds 6:

// is now returning all values, so it's ignoring the IN condition
SELECT.from(Object).where`userId IN ${aUserIDs}` 
// will result in an exception when running the query
SELECT.from(Object).where`userId IN ${aUserIDs} and type = 3` 

I therefore switched to the fluent API syntax (not sure if it's called like that):

SELECT.from(Object).where({userId: aUserIDs})
SELECT.from(Object).where({userId: aUserIDs, type: 3})

This way it's running fine again. But I wonder what is the correct syntax when using the template string literal syntax in combination with the IN operator?


Thanks & best regards

Nico

OlenaT
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi nicorunge,

Thank you for bringing it to our attention! We will fix tagged template literals and get back to you. Meanwhile please use fluent API.

Best regards,

Olena

OlenaT
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi nicorunge,

starting next release the IN operator will be case insensitive, you can use your old syntax.

Best regards,

Olena

Accepted Solutions (1)

Accepted Solutions (1)

OlenaT
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi nicorunge,

We double checked this problem, could you please try to write in in lowercase and let me know if it solves the problem?

SELECT.from(Object).where`userId in ${aUserIDs}`

Best regards,

Olena

nicorunge
Participant
0 Kudos

Hi Olena,

with lowercase "in" it works!

Thanks & BR
Nico

Answers (0)