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

PG strange error: doesn't retrieve columns, but they are there! #13

Open
frederikhors opened this issue Sep 5, 2018 · 0 comments
Open

Comments

@frederikhors
Copy link

frederikhors commented Sep 5, 2018

I have a problem this with Postgres (PG dialect). But this is really strange to me.

ENTIRE REPRODUCTION HERE (also with Postgres database online): https://glitch.com/edit/#!/postgres-join-monster

If you click on "Show Live" button it opens Graphql Playground.

The schema, resolvers and query is the same as the Readme here: https://github.com/acarl005/join-monster-graphql-tools-adapter

Can you see the error in Playground?

When I query with:

query {
  user(id: 1) {
    id
    fullName
    email
    posts {
      id
      body
      numComments
      comments {
        id
        body
        userId
      }
    }
  }
}

it says:

{
  "data": {
    "user": null
  },
  "errors": [
    {
      "message": "column posts.userid does not exist",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "user"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "name": "SequelizeDatabaseError",
          "parent": {
            "name": "error",
            "length": 104,
            "severity": "ERROR",
            "code": "42703",
            "position": "317",
            "file": "parse_relation.c",
            "line": "2876",
            "routine": "errorMissingColumn",
            "sql": "SELECT\n  \"user\".\"id\" AS \"id\",\n  \"user\".\"email\" AS \"email\",\n  \"posts\".\"id\" AS \"posts__id\",\n  (SELECT count(*) FROM comments where \"posts\".id = comments.postId) AS \"posts__numComments\",\n  \"user\".\"first_name\" AS \"first_name\",\n  \"user\".\"last_name\" AS \"last_name\"\nFROM users \"user\"\nLEFT JOIN posts \"posts\" ON \"user\".id = \"posts\".userId\nWHERE \"user\".id = 1"
          },
          "original": {
            "name": "error",
            "length": 104,
            "severity": "ERROR",
            "code": "42703",
            "position": "317",
            "file": "parse_relation.c",
            "line": "2876",
            "routine": "errorMissingColumn",
            "sql": "SELECT\n  \"user\".\"id\" AS \"id\",\n  \"user\".\"email\" AS \"email\",\n  \"posts\".\"id\" AS \"posts__id\",\n  (SELECT count(*) FROM comments where \"posts\".id = comments.postId) AS \"posts__numComments\",\n  \"user\".\"first_name\" AS \"first_name\",\n  \"user\".\"last_name\" AS \"last_name\"\nFROM users \"user\"\nLEFT JOIN posts \"posts\" ON \"user\".id = \"posts\".userId\nWHERE \"user\".id = 1"
          },
          "sql": "SELECT\n  \"user\".\"id\" AS \"id\",\n  \"user\".\"email\" AS \"email\",\n  \"posts\".\"id\" AS \"posts__id\",\n  (SELECT count(*) FROM comments where \"posts\".id = comments.postId) AS \"posts__numComments\",\n  \"user\".\"first_name\" AS \"first_name\",\n  \"user\".\"last_name\" AS \"last_name\"\nFROM users \"user\"\nLEFT JOIN posts \"posts\" ON \"user\".id = \"posts\".userId\nWHERE \"user\".id = 1",
          "stacktrace": [
            "SequelizeDatabaseError: column posts.userid does not exist",
            "    at Query.formatError (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/sequelize/4.38.0/node_modules/sequelize/lib/dialects/postgres/query.js:363:16)",
            "    at query.catch.err (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/sequelize/4.38.0/node_modules/sequelize/lib/dialects/postgres/query.js:86:18)",
            "    at tryCatcher (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/util.js:16:23)",
            "    at Promise._settlePromiseFromHandler (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/promise.js:512:31)",
            "    at Promise._settlePromise (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/promise.js:569:18)",
            "    at Promise._settlePromise0 (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/promise.js:614:10)",
            "    at Promise._settlePromises (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/promise.js:690:18)",
            "    at _drainQueueStep (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/async.js:138:12)",
            "    at _drainQueue (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/async.js:131:9)",
            "    at Async._drainQueues (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/async.js:147:5)",
            "    at Immediate.Async.drainQueues (/rbd/pnpm-volume/13dab6e7-982a-4e75-a7d2-4720db53e6c6/node_modules/.registry.npmjs.org/bluebird/3.5.2/node_modules/bluebird/js/release/async.js:17:14)",
            "    at runCallback (timers.js:810:20)",
            "    at tryOnImmediate (timers.js:768:5)",
            "    at processImmediate [as _immediateCallback] (timers.js:745:5)"
          ]
        }
      }
    }
  ]
}

If I change it from:

sqlJoin: (userTable, postTable) => ${userTable}.id = ${postTable}.userId,

to:

sqlJoin: (userTable, postTable) => ${userTable}.id = ${postTable}."userId",

it works. But there is another error after...

Where am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant