Giter Club home page Giter Club logo

Comments (7)

negativename avatar negativename commented on June 15, 2024 2

Hello.
We have encountered the same error. We analyzed it and realized that it is related to the way SAP CDS handles references. For example in your SQL statement above you filter breweries by name using association:

a.brewery.name

This SQL statement is not supported by PostgreSQL. It is suitable for SAP Hana, but for PostgreSQL we should process the association with INNER JOIN.

Please see below the code from CDS that is responsible for creation of this dot-association:
Screenshot 2022-07-16 at 14 32 40

As CDS is closed source, I can't propose to change it to more widely supported INNER JOIN construction.

One of the ideas is to revise SQL queries within cds-pg by replacing dot-associations with inner joins. We are not sure this is the best solution.

What do you think? Do you have any other ideas?

from cds-pg.

gregorwolf avatar gregorwolf commented on June 15, 2024

For better analysis of the issue please run your project with the environment variable:

DEBUG=cds-pg

set to get the generated SQL shown.

from cds-pg.

AlexandreCordaJunior avatar AlexandreCordaJunior commented on June 15, 2024

Sorry for the delay.
This are the logs shown in the console:

[cds] - GET /beershop-admin/Beers?$filter=brewery/name eq ''&$expand=brewery
[cds-pg] - sql > SELECT a.ID AS "a_ID", a.name AS "a_name", a.abv AS "a_abv", a.ibu AS "a_ibu", a.brewery_ID AS "a_brewery_ID", b.ID AS "b_ID", b.name AS "b_name", $1 AS "b_IsActiveEntity", $2 AS "b_HasActiveEntity", CASE WHEN B_DRAFTS.DRAFTADMINISTRATIVEDATA_DRAFTUUID IS NOT NULL THEN TRUE ELSE FALSE END AS "b_HasDraftEntity" FROM BeershopAdminService_Beers a LEFT JOIN BeershopAdminService_Breweries b ON ( b.ID = a.brewery_ID ) LEFT JOIN BeershopAdminService_Breweries_drafts b_drafts ON ( b_drafts.ID = b.ID ) WHERE a.brewery.name = $3 ORDER BY a.ID ASC LIMIT 1000 OFFSET 0
[cds-pg] - values > [ true, false, '' ]

from cds-pg.

gregorwolf avatar gregorwolf commented on June 15, 2024

Hi @negativename,

when needed we need to adjust the SQL in cds-pg. So it would be great if you can contribute this.

from cds-pg.

negativename avatar negativename commented on June 15, 2024

Hello,
I've created a pull request

from cds-pg.

lirudayam avatar lirudayam commented on June 15, 2024

Hello everyone
This looks like a great fix, is it possible to merge the PR asap? We have a project on CAP with PostgreSQL and this would be very helpful, if expanded $filters are possible, since we have many occurrences in our project which we tested locally on SQLite.

from cds-pg.

vobu avatar vobu commented on June 15, 2024

unfortunately the tests in #335 still fail - if you need this asap, would you mind taking a look at the failing tests and eventually contribute the fix onto the PR?

from cds-pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.