graphql-engine
graphql-engine copied to clipboard
Server: GraphQL API error with CockroachDB
Steps to reproduce:
- Connect a CockroachDB
- Select the CrDB in the navigation tree
- Click on a CDB table in the Nav Tree
You get an error response:
{
"errors": [
{
"extensions": {
"code": "unexpected",
"internal": {
"arguments": [],
"error": {
"description": "source SQL:\nSELECT json_build_object('aggregate', json_build_object('count', COUNT(*) ) ) AS \"root\" FROM (SELECT FROM (SELECT * FROM \"public\".\"cdb_posts\" WHERE ('true') ) AS \"_root.base\" ) AS \"_root\" \n ^",
"exec_status": "FatalError",
"hint": "try \\h SELECT",
"message": "at or near \"from\": syntax error",
"status_code": "42601"
},
"prepared": true,
"statement": "SELECT json_build_object('aggregate', json_build_object('count', COUNT(*) ) ) AS \"root\" FROM (SELECT FROM (SELECT * FROM \"public\".\"cdb_posts\" WHERE ('true') ) AS \"_root.base\" ) AS \"_root\" "
},
"path": "$"
},
"message": "database query error"
}
]
}
Request URL: /v1/graphql
Request Body:
{
"query": "query TableRows {\n cdb_posts (limit: 10,offset: 0) {\n title\nid\n }\n cdb_posts_aggregate {\n aggregate {\n count\n }\n }\n }",
"variables": null,
"operationName": "TableRows"
}
There's an error in the SQL statement executed on the server
SELECT json_build_object('aggregate', json_build_object('count', COUNT(*) ) ) AS "root" FROM (SELECT FROM (SELECT * FROM "public"."cdb_posts" WHERE ('true') ) AS "_root.base" ) AS "_root"
-> SELECT FROM
More information:
If you create a table in cockroachdb and don't specify a primary key cockroachdb generates a primary key for you.
More information:
If you create a table in cockroachdb and don't specify a primary key cockroachdb generates a primary key for you.
The issue seems related to the fact that CockroacHDB doesn't support this syntax SELECT FROM, while Postgres does.
We opened an issue to the CockroachDB repository to get a more consistent behavior https://github.com/cockroachdb/cockroach/issues/87428 that got closed in favour of https://github.com/cockroachdb/cockroach/issues/83255
Discussed after standup: This is blocked by https://github.com/cockroachdb/cockroach/issues/83255 but we have a workaround in progress.
Luca verified this works as expected yesterday, closing