Skip to Content

Ambiguous column name with path expression in where condition

Hello CAP team,

I'm getting the error "SQLITE_ERROR: ambiguous column name: ID", when following an association witthin a where-condition. Take the following entities as an example:

entity db.Products  {
  key ID       : Integer;
      name     : String(100);
      supplier : Association to db.Suppliers;
}
entity db.Suppliers {
  key ID       : Integer;
      name     : String(100);
      products : Association to many db.Products 
                on products.supplier = $self;
}

Now consider the following three variants of a service:

// Variant 1 --> BAD
service CQLService {
    entity Products as select from db.Products where supplier.name ='Vendor 101';
}
// Variant 2 --> BAD
service CQLService {
    entity Products as projection on db.Products where supplier.name ='Vendor 101';
}
// Variant 3  --> GOOD!
service CQLService {
    entity Products as select * from db.Products where supplier.name ='Vendor 101';
}

The query "/cql/Products" is only working as expected for variant 3 (using the *-operator). The first two variants result in the error "SQLITE_ERROR: ambiguous column name: ID". This happens for SQlite as well as for HANA.

Works as designed? Or is this an error? The documentation is a little vague on the effect of the *-operator ...

Thanks and best regards!

>> cds -v
@sap/cds: 4.2.4
@sap/cds-compiler: 1.43.0
@sap/cds-dk: 3.1.2
@sap/cds-foss: 2.1.0
@sap/cds-reflect: 2.13.1
@sap/cds-runtime: 2.5.2
Node.js: v12.18.2
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Oct 30 at 10:46 AM

    Hi Klaus, this will be fixed with the upcoming CAP release. Stay tuned!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.