payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
27.66k stars 1.72k forks source link

Join field breaks when put on collection with versions #9369

Closed alexanderbnelson closed 21 hours ago

alexanderbnelson commented 2 days ago

Describe the Bug

Join field breaks when put on a collection with versions. For example, Pages have a relation to Posts. Posts join to Pages. Both collections have versions. This error shows up [ Server ] Error: column pages_rels._posts_v_id does not exist

It could be that versions on both are required for the bug to present itself. Join works if the collection being joined TO (Pages in this example) has versions and Posts doesn't.

Link to the code that reproduces this issue

https://github.com/alexanderbnelson/payload-example

Reproduction Steps

View the code for the posts collection config.
https://github.com/alexanderbnelson/payload-example/blob/main/src/collections/Posts/index.ts

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 20.11.0
  npm: 10.9.0
  Yarn: 1.22.19
  pnpm: 9.13.2
Relevant Packages:
  payload: 3.0.1
  next: 15.0.3
  @payloadcms/db-postgres: 3.0.1
  @payloadcms/email-nodemailer: 3.0.1
  @payloadcms/graphql: 3.0.1
  @payloadcms/live-preview: 3.0.1
  @payloadcms/live-preview-react: 3.0.1
  @payloadcms/next/utilities: 3.0.1
  @payloadcms/payload-cloud: 3.0.1
  @payloadcms/plugin-form-builder: 3.0.1
  @payloadcms/plugin-nested-docs: 3.0.1
  @payloadcms/plugin-redirects: 3.0.1
  @payloadcms/plugin-search: 3.0.1
  @payloadcms/plugin-seo: 3.0.1
  @payloadcms/richtext-lexical: 3.0.1
  @payloadcms/translations: 3.0.1
  @payloadcms/ui/shared: 3.0.1
  react: 19.0.0-rc-65a56d0e-20241020
  react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:36 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12