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
25.84k stars 1.65k forks source link

Postgres / SQLite: hasMany / poly relationships nested to localized groups / tabs are broken #8455

Closed r1tsuu closed 1 month ago

r1tsuu commented 1 month ago

Link to reproduction

No response

Environment Info

Payload: 109

Describe the Bug

The email relationship field isn't transformed from the db to the local api result properly. The same would be with polymorphic / hasMany polymorphic. This is only if the field is nested to a localized group / tab

{
      name: 'localizedGroupManyRel',
      type: 'group',
      localized: true,
      fields: [
        {
          type: 'relationship',
          relationTo: 'email-fields',
          name: 'email',
          hasMany: true,
        },
      ],
    },

Reproduction Steps

With the config above try to run:

const rel_1 = await payload.create({
  collection: 'email-fields',
  data: { email: 'pro123@gmail.com' },
})

const rel_2 = await payload.create({
  collection: 'email-fields',
  data: { email: 'frank@gmail.com' },
})

const doc = await payload.create({
  collection: 'group-fields',
  depth: 0,
  data: {
    group: { text: 'requireddd' },
    localizedGroupManyRel: {
      email: [rel_1.id],
    },
  },
})

doc.localizedGroupManyRel.email doesn't contain the inserted relationship id.

Adapters and Plugins

No response

r1tsuu commented 1 month ago

Fixed in Fixed in https://github.com/payloadcms/payload/pull/8456

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] commented 1 month ago

🚀 This is included in version v3.0.0-beta.110