Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does @cap-js/hana support quoted sql mapping? #783

Open
ThePlenkov opened this issue Aug 23, 2024 · 7 comments
Open

Does @cap-js/hana support quoted sql mapping? #783

ThePlenkov opened this issue Aug 23, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@ThePlenkov
Copy link

Hi! Following the advice from SAP we've migrated to @cap-js/hana. However it seems like this connector doesn't support yet quoted sql mapping. At least our sql queries fail with error like Invalid table name: Could not find table/view API_ODATA_BUCKET_BALANCE_MONTHLY while we have it generated like this:

VIEW "api.odata.bucket_balance_monthly" AS SELECT
@ThePlenkov ThePlenkov added the bug Something isn't working label Aug 23, 2024
@johannes-vogel
Copy link
Contributor

not yet, Pr still pending #681

@ThePlenkov
Copy link
Author

just as an idea to what could be a solution. Since we have a source table like "schema.table" which gets converted to SCHEMA_TABLE, and since we generate also hdbtable, hdbview. Isn't it a good idea also to delegate to framework to generate hdbsynonym files? That would help us may be to migrate from quoted mapping if we could just rebuild the project with synonyms, generated from the model. What do you think about this? Thanks!

@ThePlenkov
Copy link
Author

So let's say in case of the entity like:

@cds.persistence.exists: true
entity namespace sap.fe.cap.Travel {
...
}

we will not generate hdbtable ( because it exists ), but we'll generate synonym ( it's ok if it's for same schema )

like
{ " SAP_FE_CAP_TRAVEL " : {
object: "sap.fe.cap.Travel"
}
}

@ThePlenkov
Copy link
Author

I've just got a wild issue finding out why quoted is important.

So somehow our data team managed to create tables with columns called "timestamp" in lower case
image

So I have a view like:


@cds.persistence.exists: true
entity Entity {
...
      @title: 'Expiration Date'
      EXPIRY_TS              : Timestamp;
      timestamp              : Timestamp;
};

which ends up in hdbview once I consume it:

  asset_relationships_0.expiry_ts,
  asset_relationships_0."TIMESTAMP",
  asset_relationships_0.effective_ts,

because of this "TIMESTAMP" i have an error during deployment

Error: com.sap.hana.di.view: Database error 260: : invalid column name: BIZENTASSETRELATIONSHIPS_0.TIMESTAMP:

This transformation happens in a function smartId which automatically transforms lowercase words like "timestamp" to upper case if it's one of the reserved words.

image

Unfortunately this makes us not possible to use plain sql mapping in our project anyhow. Because we cannot even deploy artifacts for such tables.

May be it's a complex issue and it also needs to be addressed to a relavant team.

@ThePlenkov
Copy link
Author

@johannes-vogel do you know which team to address mentioned above problem with cds compiler which compiles hdbview which is not possible to deploy if sql mode is plain? Thanks!

@ThePlenkov
Copy link
Author

@danjoa Daniel, do you know may be - is it possible to generate hdbview with columns like "timestamp" in a lower case if plain mode is used? Thanks!

@ThePlenkov
Copy link
Author

@danjoa one more point about usage of npm dependencies. Now to test the logic with and without @cap-js/hana I have to change package.json dependencies and reinstall packages every time. This is very inconvenient. I'm sure there must be a better way not to use hew driver / plugin even if it's being installed, right? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants