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

Relationship block field breaks on search because of default search #6226

Open
matteo-naif opened this issue May 6, 2024 · 0 comments
Open
Labels
[possible-bug] Possible bug which hasn't been reproduced yet

Comments

@matteo-naif
Copy link

Link to reproduction

Describe the Bug

When I try to filter the documents of a relationship field it breaks.
When I type a letter to filter by title, it query by publishDate that is the defaultSort value of the collection.
I can't find a way to specify in the relationship field how to specify the field to use for the query.

To Reproduce

  1. Add the block
  2. Open the field relationship
  3. In the network a GET request is sent
  • url: http://localhost:3000/api/posts
  • Query string:
    • depth: 0
    • draft: true
    • limit: 10
    • locale: it-IT
    • page: 1
    • sort: publishDate
  • status: 200
  1. type in the filter of the relationship
  2. In the network a new GET request is sent
  • url: http://localhost:3000/api/posts
  • Query string:
    • depth: 0
    • draft: true
    • limit: 10
    • locale: it-IT
    • page: 1
    • sort: publishDate
    • where[and][1][publishDate][like]: a
  • status: 500
  1. In the server console the error that appear is
[15:35:51] ERROR (payload): TypeError: Cannot destructure property 'operator' of '(0 , _sanitizeQueryValue.sanitizeQueryValue)(...)' as it is undefined.
    at buildSearchParam (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/buildSearchParams.ts:97:17)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async parseParams (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/parseParams.ts:60:35)
    at async buildAndOrConditions (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/buildAndOrConditions.ts:29:22)
    at async parseParams (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/parseParams.ts:43:33)
    at async buildAndOrConditions (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/buildAndOrConditions.ts:29:22)
    at async parseParams (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/parseParams.ts:43:33)
    at async buildAndOrConditions (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/buildAndOrConditions.ts:29:22)
    at async parseParams (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/parseParams.ts:43:33)
    at async Function.buildQuery (/Users/matteotortelli/progetti/evoluzione/evoluzione-backend/node_modules/@payloadcms/db-mongodb/src/queries/buildQuery.ts:43:22)

Payload Version

2.14.2

Adapters and Plugins

	"@payloadcms/bundler-webpack": "1.0.6", 		"@payloadcms/db-mongodb": "1.5.1", 		"@payloadcms/plugin-cloud-storage": "1.1.2", 		"@payloadcms/plugin-form-builder": "1.2.2", 		"@payloadcms/plugin-nested-docs": "1.0.12", 		"@payloadcms/plugin-seo": "2.3.2", 		"@payloadcms/richtext-lexical": "0.9.2", 		"@payloadcms/richtext-slate": "1.5.1",
@matteo-naif matteo-naif added the [possible-bug] Possible bug which hasn't been reproduced yet label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[possible-bug] Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant