-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
bugSomething isn't workingSomething isn't workingcqn2sqlcqn-to-sql transformationcqn-to-sql transformation
Description
Go into the bookshop and start a repl session:
> sql = `
... SELECT author_name, total_books
... FROM (
... SELECT
... a.name AS author_name,
... COUNT(b.ID) AS total_books
... FROM sap_capire_bookshop_Authors a
... LEFT JOIN sap_capire_bookshop_Books b ON a.ID = b.author_ID
... GROUP BY a.name
... ) AS author_summary
... ORDER BY total_books DESC;
> await cds.run(sql)
[
{ author_name: 'Edgar Allen Poe', total_books: 2 },
{ author_name: 'Charlotte Brontë', total_books: 1 },
{ author_name: 'Emily Brontë', total_books: 1 },
{ author_name: 'Richard Carpenter', total_books: 1 }
]so far so good. We had a customer doing (weird) stuff like this:
> await cds.run( cds.parse.cql(sql) )
Uncaught Error: "sap_capire_bookshop_Authors" not found in the definitions of your model
at inferTarget (/Users/patricebender/SAPDevelop/dev/cds-dbs/db-service/lib/infer/index.js:105:53)what usually doesn't bother us, because here:
cds-dbs/db-service/lib/SQLService.js
Lines 395 to 403 in b1ecb6c
| cqn4sql(q) { | |
| if ( | |
| !cds.env.features.db_strict && | |
| !q.SELECT?.from?.join && | |
| !q.SELECT?.from?.SELECT && | |
| !this.model?.definitions[_target_name4(q)] | |
| ) return q | |
| else return cqn4sql(q, this.model) | |
| } |
we check for non-modeled entities and if that is the case, we just send the query to the database. However, that mechanism does not work, because the unresolvable entity lives within the subquery.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcqn2sqlcqn-to-sql transformationcqn-to-sql transformation