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.
Using Postgres Adapter: When using a localized field in an array that is part of another array, an error is thrown when inserting a second entry.
Let's start with adding localization to the Payload config and localize the provided link field definition by adding localized: true to a links label. Then, for example in the posts collection, we add the following field definition to create a menu
I know this does not make sense by itself, but just imagine adding a title field to each menu as well (which is what I wanted to do in my app). This is just to provide the smallest possible reproduction.
When I add one menu with one link to a post, everything works. But when I insert a second menu with one link, an error is thrown:
[10:07:08] ERROR: There was an error while saving a version for the Post with ID 1.
[10:07:08] ERROR: Cannot read properties of undefined (reading '_posts_v_version_menu_items_locales_locale_parent_id_unique')
err: {
"type": "TypeError",
"message": "Cannot read properties of undefined (reading '_posts_v_version_menu_items_locales_locale_parent_id_unique')",
I already checked if it has to do with the generated table, column or index name lengths, but the bug happens even with custom shorter dbName overrides.
The setup works perfectly with the Mongo DB Adapter.
BTW: I wanted to do this for the header and footer globals, and it does not work for globals either when versions are enabled.
Link to reproduction
https://github.com/HappyEmu/payload-30-postgres-menu-reprod
Payload Version
3.0.0-beta.79
Node Version
v20.9.0
Next.js Version
15.0.0-canary.104
Describe the Bug
Using Postgres Adapter: When using a localized field in an array that is part of another array, an error is thrown when inserting a second entry.
Let's start with adding localization to the Payload config and localize the provided
link
field definition by addinglocalized: true
to alink
slabel
. Then, for example in theposts
collection, we add the following field definition to create a menuI know this does not make sense by itself, but just imagine adding a
title
field to eachmenu
as well (which is what I wanted to do in my app). This is just to provide the smallest possible reproduction.When I add one
menu
with onelink
to apost
, everything works. But when I insert a secondmenu
with onelink
, an error is thrown:I already checked if it has to do with the generated table, column or index name lengths, but the bug happens even with custom shorter
dbName
overrides.The setup works perfectly with the Mongo DB Adapter.
BTW: I wanted to do this for the
header
andfooter
globals, and it does not work for globals either when versions are enabled.Reproduction Steps
label
oflink
menu
field topost
collectionTry to save
post
with 2 menus with 1 entry each. This will fail with above mentioned error.Adapters and Plugins
db-postgres