Skip to content

Blank screen when filtering a collection for certain array values with "equals" instead of "is in" #15387

Closed

Description

@jaymaycry

Describe the Bug

When I try to filter a collection on a property that is a hasMany relation and use the "equals" operator I get a blank screen and the following error:

[Error: Failed query: select distinct "users"."id", "users"."created_at", "users"."created_at" from "users" left join "users_rels" "4f704f54_123f_4661_90e5_71f0edee30e2" on ("users"."id" = "4f704f54_123f_4661_90e5_71f0edee30e2"."parent_id" and "4f704f54_123f_4661_90e5_71f0edee30e2"."path" like $1) left join "interests" "f1c01e26_80fb_4c44_9c38_5b99a8ce7377" on "f1c01e26_80fb_4c44_9c38_5b99a8ce7377"."id" = "4f704f54_123f_4661_90e5_71f0edee30e2"."interests_id" where "4f704f54_123f_4661_90e5_71f0edee30e2"."interests_id" = $2 order by "users"."created_at" desc limit $3
params: interests,2,2,10] {
query: 'select distinct "users"."id", "users"."created_at", "users"."created_at" from "users" left join "users_rels" "4f704f54_123f_4661_90e5_71f0edee30e2" on ("users"."id" = "4f704f54_123f_4661_90e5_71f0edee30e2"."parent_id" and "4f704f54_123f_4661_90e5_71f0edee30e2"."path" like $1) left join "interests" "f1c01e26_80fb_4c44_9c38_5b99a8ce7377" on "f1c01e26_80fb_4c44_9c38_5b99a8ce7377"."id" = "4f704f54_123f_4661_90e5_71f0edee30e2"."interests_id" where "4f704f54_123f_4661_90e5_71f0edee30e2"."interests_id" = $2 order by "users"."created_at" desc limit $3',
params: [Array],
[cause]: [error: invalid input syntax for type integer: "{"2","2"}"] {
length: 152,
severity: 'ERROR',
code: '22P02',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: "unnamed portal parameter $2 = '...'",
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'numutils.c',
line: '616',
routine: 'pg_strtoint32_safe'
}
}

Link to the code that reproduces this issue

https://github.com/jaymaycry/payload-array-filter-issue

Reproduction Steps

  1. Login and create user
  2. Create one or two interests and link one to the user
  3. Go to collection and add a filter "Interests" "equals" and one of the created interests
    => menu dissapears

Which area(s) are affected?

area: ui

Environment Info

Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  payload: 3.72.0
  next: 15.4.10
  @payloadcms/db-postgres: 3.72.0
  @payloadcms/drizzle: 3.72.0
  @payloadcms/graphql: 3.72.0
  @payloadcms/next/utilities: 3.72.0
  @payloadcms/richtext-lexical: 3.72.0
  @payloadcms/translations: 3.72.0
  @payloadcms/ui/shared: 3.72.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Jan 28, 2026
  2. added
    area: ui
    and removed
    validate-reproduction
    on Jan 28, 2026
  3. removed
    status: needs-triage
    on Jan 28, 2026
  4. RisaI commented on Jan 29, 2026

    @RisaI

    Similar errors can be encountered when filtering a richText column by a contains action:

    Error: Failed query: select count(*) from "media" where "media"."caption" ilike $1
    params: %asd%
        at ignore-listed frames {
      query: 'select count(*) from "media" where "media"."caption" ilike $1',
      params: [Array],
      [cause]: error: operator does not exist: jsonb ~~* unknown
          at ignore-listed frames {
        length: 202,
        severity: 'ERROR',
        code: '42883',
        detail: undefined,
        hint: 'No operator matches the given name and argument types. You might need to add explicit type casts.',
        position: '54',
        [...]
        constraint: undefined,
        file: 'parse_oper.c',
        line: '635',
        routine: 'op_error'
      }
    }
    
  5. nehaaprasad commented on Jan 29, 2026

    @nehaaprasad
    Contributor

    Hello! @jaymaycry
    please check out the PR!

  6. JarrodMFlesch commented on Jan 30, 2026

    @JarrodMFlesch
    Contributor

    @naaa760 I think the fix here would be to focus on the frontend and not allow the list filter to show equals/not_equals when a field has hasMany: true.

  7. nehaaprasad commented on Feb 2, 2026

    @nehaaprasad
    Contributor

    @JarrodMFlesch
    updated it, please check it out!

  8. jaymaycry commented on Feb 9, 2026

    @jaymaycry
    Author

    @naaa760 lgtm, thank you!

  9. JarrodMFlesch commented on Oct 27, 2026

    @JarrodMFlesch
    Contributor

    This is fixed in #15766, released in 3.82.0. The SQL adapter now converts array-valued relationship equals/not_equals filters to in/not_in instead of passing an array to a scalar comparison.

    I verified the reported relationship-filter failure on PostgreSQL with Payload 3.92.0 and 4.0.0-beta.4. The database checks pass with scalar, single-value, multiple-value, and duplicate array inputs, using both serial and UUID IDs. The recordings below show the Admin list filtering successfully on each version.

    This closes the original relationship-filter report; the separate rich-text contains example in the comments is a different query path.

    PYLD-598-3x-take2.mp4
    PYLD-598-main-take2.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugarea: ui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions