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

Join field not working with versioning enabled #8680

Closed
foxted opened this issue Oct 14, 2024 · 2 comments
Closed

Join field not working with versioning enabled #8680

foxted opened this issue Oct 14, 2024 · 2 comments
Assignees

Comments

@foxted
Copy link

foxted commented Oct 14, 2024

Link to reproduction

No response

Environment Info

Payload: 3.0.0-beta.113
Node: 20.16.0
pnpm: 9.12.1

Describe the Bug

I am trying to use joins for a collection and I am faced with this error:

⨯ TypeError: Cannot read properties of undefined (reading 'articles')
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
digest: "2347669909"
  709 |                     const fieldSchemaPath = `${fieldPrefix || ''}${field.name}`;
  710 |                     let target;
> 711 |                     const joinConfig = joins[field.collection].find(({ schemaPath })=>fieldSchemaPath === schemaPath);
      | ^
  712 |                     if (joinConfig.targetField.hasMany) {
  713 |                         target = `${adapter.tableNameMap.get(toSnakeCase(field.collection))}${adapter.relationshipsSuffix}`;
  714 |                     } else {

Here's my relationship field on the articles collection:

{
  name: 'chapter',
  type: 'relationship',
  relationTo: 'chapters',
  hasMany: false,
}

And here's the join field on the chapters collection:

{
  name: 'relatedArticles',
  type: 'join',
  collection: 'articles',
  on: 'chapter',
}

Reproduction Steps

  • Create two collections with versioning enabled
  • Create a relationship field on one of the collection
  • Create a join field on the other collection

Adapters and Plugins

db-postgres

@foxted foxted added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Oct 14, 2024
@r1tsuu r1tsuu self-assigned this Oct 15, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Oct 15, 2024
DanRibbens pushed a commit that referenced this issue Oct 22, 2024
- Fixes errors with drizzle when building the schema
#8680
- Adds `joins` to `db.queryDrafts` to have them when doing `.find` with
`draft: true`
@r1tsuu
Copy link
Member

r1tsuu commented Oct 22, 2024

Fixed in #8715

@r1tsuu r1tsuu closed this as completed Oct 22, 2024
Copy link
Contributor

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants