directus / directus

The Modern Data Stack 🐰 — Directus is an instant REST+GraphQL API and intuitive no-code data collaboration app for any SQL database.

Home Page:https://directus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ItemsService in extensions fails on table with BigInt primary key

izoukhai opened this issue · comments

Describe the Bug

Trying to do operations on a table with a BigInt primary key with extension's ItemsService leads to failure with the following message:

err: { directus-1 | "type": "TypeError", directus-1 | "message": "Cannot read properties of undefined (reading 'fields')", directus-1 | "stack": directus-1 | TypeError: Cannot read properties of undefined (reading 'fields') directus-1 | at getASTFromQuery (file:///directus/node_modules/.pnpm/@directus+api@file+api_@aws-sdk+client-sso-oidc@3.569.0_@aws-sdk+client-sts@3.569.0_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/utils/get-ast-from-query.js:23:15) directus-1 | at ItemsService.readByQuery (file:///directus/node_modules/.pnpm/@directus+api@file+api_@aws-sdk+client-sso-oidc@3.569.0_@aws-sdk+client-sts@3.569.0_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/services/items.js:316:25) directus-1 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) directus-1 | at async file:///directus/extensions/directus-extension-endpoint-minigames/dist/index.js?t=1715715532960:4397:9 directus-1 | }

To Reproduce

Just create a table with a BigInt primary key. Other tables work perfectly.

const testService = new ctx.services.ItemsService("test", {
         schema
       });

       ctx.logger.warn("TESTING TEST SERVICE...");
       await testService.readByQuery();

       ctx.logger.warn("TESTING TEST SERVICE... DONE");

Directus Version

v10.11.0

Hosting Strategy

Self-Hosted (Docker Image)

Database

PostgreSQL 16.2

The error itself doesnt look to be related to a big int key but rather service.readByQuery() is missing the required first query parameter. Try adding an empty object if you're not querying anything specific:

await testService.readByQuery({});

closing this issue for now but happy to re-open if im incorrect 😄

The error itself doesnt look to be related to a big int key but rather service.readByQuery() is missing the required first query parameter. Try adding an empty object if you're not querying anything specific:

await testService.readByQuery({});

closing this issue for now but happy to re-open if im incorrect 😄

My bad, I forgot to add the empty object.
But it's still not working even with an empty object

Are you getting a different error then i'd expect?

Nope, the exact same error as above

Alright, my bad again I had a typo in my table name.
However, I find it weird that I still have the issue with the new table "test" I created

Could that perhaps be cache? on second look the error would indicate that the collection you're using is not in the provided schema as it tries to do schema[collection].fields (which would throw the accessing fields of undefined error)

Totally, just ran some tests it is indeed related to cache ;)