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

Malformed array literal error after counting records with empty array field #9353

Open
BOHEUS opened this issue Jan 5, 2025 · 1 comment

Comments

@BOHEUS
Copy link
Contributor

BOHEUS commented Jan 5, 2025

Preconditions: Object must have array field type

Scenario:

  1. Log in
  2. Go to objects tab
  3. Select "Count empty" or "Count not empty" on array field type
  4. Edit any record's data

Actual: In UI and logs there's error every time user edits any record's data of this specific object

Screencast.From.2025-01-05.14-35-15.mp4

Expected: It should be possible to count records with empty or not empty array field

Logs:

query failed: SELECT CASE WHEN COUNT(*) = 0 THEN NULL ELSE COUNT(NULLIF("array", '')) END AS "countNotEmptyArray" FROM "workspace_1wgvd1injqtife6y4rvfbu3h5"."_a" "a" WHERE "a"."deletedAt" IS NULL
error: error: malformed array literal: ""
Exception Captured
  {
    operation: { name: 'AggregateAs', type: 'query' },
    document: 'query AggregateAs($filter: AFilterInput) {\n' +
      '  as(filter: $filter) {\n' +
      '    countNotEmptyArray\n' +
      '    __typename\n' +
      '  }\n' +
      '}',
    user: User {
      id: '20202020-9e3b-46d4-a556-88b9ddc2b034',
      firstName: 'Tim',
      lastName: 'Apple',
      email: 'tim@apple.dev',
      defaultAvatarUrl: null,
      emailVerified: false,
      disabled: false,
      passwordHash: '$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6',
      canImpersonate: false,
      createdAt: 2025-01-02T21:50:07.032Z,
      updatedAt: 2025-01-02T21:50:07.032Z,
      deletedAt: null
    },
    workspace: {
      id: '20202020-1c25-4d02-bf25-6aeccf7ea419',
      displayName: 'Apple',
      createdAt: '2025-01-02T21:50:07.026Z',
      activationStatus: 'ACTIVE'
    }
  }
  [
    QueryFailedError: malformed array literal: ""
        at PostgresQueryRunner.query (/home/user/Desktop/projects/twenty/src/driver/postgres/PostgresQueryRunner.ts:331:19)
        at processTicksAndRejections (node:internal/process/task_queues:95:5)
        at SelectQueryBuilder.loadRawResults (/home/user/Desktop/projects/twenty/src/query-builder/SelectQueryBuilder.ts:3805:25)
        at SelectQueryBuilder.getRawMany (/home/user/Desktop/projects/twenty/src/query-builder/SelectQueryBuilder.ts:1626:29)
        at SelectQueryBuilder.getRawOne (/home/user/Desktop/projects/twenty/src/query-builder/SelectQueryBuilder.ts:1603:17)
        at GraphqlQueryFindManyResolverService.resolve (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-find-many-resolver.service.ts:157:7)
        at GraphqlQueryFindManyResolverService.execute (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/interfaces/base-resolver-service.ts:111:23)
        at Object.as (/home/user/Desktop/projects/twenty/packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/find-many-resolver.factory.ts:37:14)
        at field.resolve (/home/user/Desktop/projects/twenty/node_modules/@envelop/on-resolve/cjs/index.js:36:42)
        at /home/user/Desktop/projects/twenty/node_modules/graphql-yoga/node_modules/@graphql-tools/executor/cjs/execution/promiseForObject.js:18:35 {
      path: undefined,
      locations: undefined,
      extensions: {
        code: 'INTERNAL_SERVER_ERROR',
        response: 'malformed array literal: ""'
      }
    }
  ]
@BOHEUS
Copy link
Contributor Author

BOHEUS commented Jan 5, 2025

Related to #9349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants