Comments (7)
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:
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.
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.
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.
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.
Hello,
I've created a pull request
from cds-pg.
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.
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)
- Invalid SQL query when Draft Entity make reference to other Draft Entity in OData call. HOT 3
- Vulnerability in momentjs 2.9.1 HOT 3
- Error upon modifying view in service HOT 1
- Strong security issue regarding indirect dependency to jsonwebtoken npm-module 8.x
- PATCH is executed on active entity for drafts with compositions HOT 3
- Error: [cds-dbm] - failed to load model undefined (STDERR, APP/TASK/deploy-to-postgresql)# HOT 2
- TypeError: Cannot read properties of undefined (reading 'definitions') HOT 4
- connection closed after each query
- Date conversion interprets timezone incorrectly
- Get request on entity not working
- Retain Column Name as case sensitive during deployment
- Wrong type cast of boolean HOT 1
- Query draft entities on db layer
- broken connectivity in 0.1.36 when using "cds watch" instead of "cds serve". using cap cds 6.6
- error: relation "[tablename]" does not exist
- duplicate key entry HOT 2
- cds-pg deploy fails with "Cannot find module '@sap/cds/lib/deploy'"
- Initial Release schedule?
- ERROR: syntax error at or near "LOCK" at character - STATEMENT: SELECT 1 FROM My_Type ALIAS_1 WHERE ( code = 1 ) LIMIT 1 FOR SHARE LOCK
- Query values must be an array ERROR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cds-pg.