Closed Rhys97W closed 1 month ago
We faced the same issue with CosmosDB and versioned collections. Once I disabled the versioning on collections, the problem was resolved. Any idea when this will be fixed? We can't enable the preview and versioning of collections otherwise.
EDIT2:
So doing a rough patch (This probably breaks other things) and ignoring using the getQueryDraftsSort for the id field fixes the issue with id sorting, as something has broken the sort and it ends up being passed as "version.id" to sort on instead of _id
diff --git a/dist/collections/operations/find.js b/dist/collections/operations/find.js
index 2e28881c9b3e3adc35dd1f1ea22a5f386cece055..a40fc7e87dd671a6cecab6b35512dffdb8e44a25 100644
--- a/dist/collections/operations/find.js
+++ b/dist/collections/operations/find.js
@@ -84,6 +84,12 @@ async function find(incomingArgs) {
versionFields: (0, _buildCollectionFields.buildVersionCollectionFields)(collection.config),
where: fullWhere
});
+
+ let sortTransform = sort;
+ if(sort !== "id"){
+ sortTransform = (0, _getQueryDraftsSort.getQueryDraftsSort)(sort)
+ }
+
result = await payload.db.queryDrafts({
collection: collectionConfig.slug,
limit: sanitizedLimit,
@@ -91,7 +97,7 @@ async function find(incomingArgs) {
page: sanitizedPage,
pagination: usePagination,
req,
- sort: (0, _getQueryDraftsSort.getQueryDraftsSort)(sort),
+ sort: sortTransform,
where: fullWhere
});
} else {
EDIT 1:
This broke the collection list... looks like defaultSort does not work with the collection list page and versions, it attempts to sort on a root field for the _versions mongo table which instead lives under the version field.... ugggh
I hit the same issue and it usually means that a field has not been indexed, the exact issue I hit was when selecting a relationship it would error due to a missing id
index.
The url it was requesting was:
api/pages?depth=0&draft=true&limit=10&page=1&sort=id
which wanted to sort on id, at least in my pages collection I had the useAsTitle
and listSearchable
fields set to url
(Custom field) so adding defaultsort: "url"
made payload now sort the collection by a known indexed field.
admin: {
useAsTitle: "url",
listSearchableFields: ["url"],
preview: (doc) => formatPreviewUrl("pages", doc),
},
defaultSort: "url",
Maybe a better way would be to figure out why id
is not being indexed anymore, and how to add it, but this atleast got my site working again
This is still an issue on the latest beta version, even when using the website template via create-payload-app@beta, straight out of the gate it errors with 400.
🚀 This is included in version v3.0.0-beta.110
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
https://github.com/MeridianTrustDev/meridian-cms/tree/test
Payload Version
3.0.0-beta.35
Node Version
20.11.1
Next.js Version
14.3.0-canary.68
Describe the Bug
When opening a relationship selection field where the target collection has versioning enabled, it throws "An error has occurred", writes the below to console and renders the field unusable. This was an issue previously and was resolved by this issue: https://github.com/payloadcms/payload/issues/4273 however has become an issue again and the issue still happens with
Reproduction Steps
To reproduce I navigate to any collection with a relationship field, attempt to open the relationship dropdown and it immedietly errors. I have narrowed down the issue to be caused between 3.0.0-beta.34 and 3.0.0-beta.35, whereby the fields work in 34 but break in 35.
Adapters and Plugins
db-mongodb, richtext-lexical, plugin-nested-docs, storage-azure, plugin-seo