Giter Club home page Giter Club logo

Comments (16)

gregorwolf avatar gregorwolf commented on June 15, 2024

Do you get this error also when running pg-beershop locally instead of your own project?

from cds-pg.

pinakipatrapro avatar pinakipatrapro commented on June 15, 2024

@TNFlexso Can you try the below config? Works fine for me.


"dependencies": {
      "@sap/cds": "5.8.4",
      "cds-dbm": "~0.0.36",
      "cds-pg": "0.1.26",
      "express": "^4",
      "@sap/cds-odata-v2-adapter-proxy":"*"
    },
    "cds": {
      "requires": {
        "db": {
          "kind": "database"
        },
        "database": {
          "dialect": "plain",
          "impl": "cds-pg",
          "model": [
            "models",
            "services"
          ],
          "credentials": {

          }
        }
      }
}

from cds-pg.

binpath avatar binpath commented on June 15, 2024

Hi I have this same issue, any ideas on how to solve it?

from cds-pg.

gregorwolf avatar gregorwolf commented on June 15, 2024

Hi @binpath

please provide details about your environment and how to reproduce the issue.

CU
Gregor

from cds-pg.

binpath avatar binpath commented on June 15, 2024

Hi @gregorwolf,

DB

My database is in a docker version 14.1
`version: '3.8'

services:
db:
image: postgres:14.1-alpine
volumes:
- db_data:/var/postgresql/data
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
PGDATA: /var/lib/postgresql/data/pgdata
adminer:
image: adminer
restart: always
ports:
- 8080:8080

volumes:
db_data:`

Then I ran docker_compose up connect to adminer and create the database manually

CAP

The CAP project is in another docker
`ARG VARIANT="16-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}

WORKDIR /code

RUN wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | apt-key add - ;
echo "deb https://packages.cloudfoundry.org/debian stable main" | tee /etc/apt/sources.list.d/cloudfoundry-cli.list

RUN apt-get update
&& apt-get -y install --no-install-recommends cf7-cli sqlite openjdk-11-jre

COPY . .

RUN su node -c "npm install -g @ui5/cli @sap/cds-dk yo generator-easy-ui5 hana-cli"`

I create the image docker build and run it later in the same network
docker run --rm -it --name dev --net=dev_default -p 4004:4004 -v $(pwd):/code binpath/dev:1.0 /bin/bash

Environment
root ➜ /code $ cds --version
@sap/cds: 5.1.5
@sap/cds-compiler: 2.13.8
@sap/cds-dk: 4.9.2
@sap/cds-foss: 2.3.1
@sap/cds-runtime: 3.1.2
Node.js: v16.14.0
home: /code/node_modules/@sap/cds

I deploy
npx cds-dbm deploy

Finally, I start the enviroment
npm start

I select my entity

[INTERNAL ERROR] TypeError: Cannot read properties of undefined (reading 'regularRegex') at smartId (/code/node_modules/@sap/cds-compiler/lib/sql-identifier.js:66:9) at _smartId (/code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:19:23) at PGReferenceBuilder.plain [as _quoteElement] (/code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:46:12) at /code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:49 at Array.map (<anonymous>) at PGReferenceBuilder._parseReference (/code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:34) at PGReferenceBuilder.build (/code/node_modules/cds-pg/lib/pg/sql-builder/ReferenceBuilder.js:44:52) at PGSelectBuilder._buildRefElement (/code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:272:68) at PGSelectBuilder._buildElement (/code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:246:18) at /code/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:311:56

Thanks

from cds-pg.

gregorwolf avatar gregorwolf commented on June 15, 2024

Hi @binpath,

do you have your project in a public Git repo? Have you tried with pg-beershop?

CU
Gregor

from cds-pg.

binpath avatar binpath commented on June 15, 2024

Hi @gregorwolf no is just a simple cds init, with a Base entity.

from cds-pg.

octavonu avatar octavonu commented on June 15, 2024

Plese try
...
"requires": {
"db": {
"kind": "postgres",
"dialect": "plain"
},

image

from cds-pg.

Multisaft7 avatar Multisaft7 commented on June 15, 2024

Update: The problem seems to be the a sap/cds version higher then 5.9.8. Now my problem is solved

I got the same issue. here is my public repo: Repo

[cds] - GET /catalog/Parties [cds] - TypeError: Cannot read properties of undefined (reading 'regularRegex') at smartId (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds-compiler/lib/sql-identifier.js:66:9) at _smartId (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:19:23) at PGReferenceBuilder.plain [as _quoteElement] (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:46:12) at /Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:49 at Array.map (<anonymous>) at PGReferenceBuilder._parseReference (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:34) at PGReferenceBuilder.build (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/lib/pg/sql-builder/ReferenceBuilder.js:44:52) at PGSelectBuilder._buildRefElement (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:272:68) at PGSelectBuilder._buildElement (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:246:18) at /Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:311:56 { id: '1643917', level: 'ERROR', timestamp: 1661772351579 } [INTERNAL ERROR] TypeError: Cannot read properties of undefined (reading 'regularRegex') at smartId (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds-compiler/lib/sql-identifier.js:66:9) at _smartId (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:19:23) at PGReferenceBuilder.plain [as _quoteElement] (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/common/utils/quotingStyles.js:46:12) at /Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:49 at Array.map (<anonymous>) at PGReferenceBuilder._parseReference (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/ReferenceBuilder.js:106:34) at PGReferenceBuilder.build (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/lib/pg/sql-builder/ReferenceBuilder.js:44:52) at PGSelectBuilder._buildRefElement (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:272:68) at PGSelectBuilder._buildElement (/Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:246:18) at /Users/A3886136/Documents/VSCode/tdao_parties/node_modules/cds-pg/node_modules/@sap/cds/libx/_runtime/db/sql-builder/SelectBuilder.js:311:56

For me the service is crashing when i try to open my data on the service... $catalog & $metadata are opening

from cds-pg.

gregorwolf avatar gregorwolf commented on June 15, 2024

Correct CAP 6 is not yet supported.

from cds-pg.

qu-42 avatar qu-42 commented on June 15, 2024

Hi,
I followed the documentation on the README and after 1/2 hour debugging I recognized it's bundled with this issue.
Finally @octavonu approach will solve it.

It's not clear to me if this is the solution or a workaround in your point of view.
Hint for theerror detechtion / solution:

  1. if @octavonu approach will should be the solution - then please correct it in the README

  2. if the configuration should be as the documented in the README, then the configuration will not correct filled for processing in cds serve
    The error will raise in the function smartID of cds application (see above error message) - not in the pg driver.
    But I guess the pg-driver does not intialize the configuration correctly.
    Due to a || construct in function smartID of cds the database configuration name will be taken, not the dialect, the dialect is not filled with the config item.
    In other words, if you name the configuration "plain" instead of "postgres" it will work as well, due in smartID it's an || withe the dialect (But I am pretty sure, this was not the design goal).
    Sorry, but I didn't have the nerve to find out, where the dialect hast to be filled in the driver initialization, if the configuration should being approached as in the README.md.
    Anyway, hope it'll help a little bit.
    Regards

from cds-pg.

luizcarlospedrosogomes avatar luizcarlospedrosogomes commented on June 15, 2024

Correct CAP 6 is not yet supported.

Do you have a prediction of when this will happen?

from cds-pg.

vobu avatar vobu commented on June 15, 2024

we're meeting with the CAP core team tomorrow evening CEST to discuss how to best jointly move forward.
we'll check back in on this gh repo's discussions or similar.

from cds-pg.

binpath avatar binpath commented on June 15, 2024

from cds-pg.

vobu avatar vobu commented on June 15, 2024

it got postponed to today, 14:30 CEST. i'll check ping back afterwards to

  • #285 (here)
  • #355
  • #343
    most likely via a gh "discussions" announcement

from cds-pg.

frankmeertens avatar frankmeertens commented on June 15, 2024

While the test suite is running without issue, manual tests to query against the database are failing.
It seems to be related to the code shown below where the dialect is not being set. Adding "dialect": "plain" to the cds.requires.db seems to solve the problem.

image

The automated testing uses the _runLocal.js to set these properties. This is likely the reason why the tests are are successful.

  const dbProperties = {
    kind: 'postgres',
    dialect: 'plain',
    model: model,
    credentials: credentials,
  }

  deployDB ? await cds.deploy(model, {}).to(dbProperties) : null

  cds.db = await cds.connect.to(dbProperties)

Comparing the as-pg-packages.json has the following.

{
  "cds": {
    "requires": {
      "db": {
        "kind": "database"
      },
      "database": {
        "dialect": "plain",
        "impl": "../../../",
        "model": ["srv"]
      }
    }
  }
}

Dialect is not maintained at the db level. Adding "dialect": "plain" resolves the problem caused by the quotingStyles.js.

module.exports = {
  plain: s => {
    // set _dialect and _reserved once cds.db.kind is set
    if (!_dialect && cds.db && cds.db.kind) {
      _dialect = cds.db.options.dialect || cds.db.kind
    }

So far, manual testing seems to be successful.

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.