diff --git a/db-service/test/cqn4sql/where-exists.test.js b/db-service/test/cqn4sql/where-exists.test.js index a67300017..7c39cf202 100644 --- a/db-service/test/cqn4sql/where-exists.test.js +++ b/db-service/test/cqn4sql/where-exists.test.js @@ -1619,4 +1619,24 @@ describe('path expression within infix filter following exists predicate', () => )`, ) }) + + it('custom where exists with path expression', () => { + expect( + cqn4sql( + CQL`SELECT from bookshop.Authors { ID } WHERE EXISTS ( + SELECT 1 FROM bookshop.Books as books + WHERE books.author_ID = books.author.ID and books.ID = 'ebf36bd9-4ef8-4d06-b83e-ffacf2b7fb59' + )`, + model, + ), + ).to.eql( + CQL`SELECT from bookshop.Authors as Authors { Authors.ID } + WHERE EXISTS ( + SELECT 1 from bookshop.Books as books + inner join bookshop.Authors as authors + on books.author_ID = authors.ID + where books.author_ID = authors.ID AND books.ID = 'ebf36bd9-4ef8-4d06-b83e-ffacf2b7fb59' + )`, + ) + }) })