Skip to content

fix: fixes creation of related documents within a transaction if filterOptions is used - #4087

Merged
DanRibbens merged 1 commit into
payloadcms:mainfrom
diesieben07:issue/4078/relationship-validation-transactions
Nov 10, 2023
Merged

DanRibbens merged 1 commit into
payloadcms:mainfrom
diesieben07:issue/4078/relationship-validation-transactions

Conversation

@diesieben07

Copy link
Copy Markdown
Contributor

Description

Fixes #4078

Fixes validation of filterOptions by passing in the current PayloadRequest, so it will use the active transaction (if any). In case this is not done, the validation code will fail to see any new documents that were created within the transaction (because it runs outside it) and thus throw a ValidationError.

The test I have written is currently only effective under Postgres, because the current MongoDB tests do not use a ReplicaSet (and thus no transactions are possible). I have verified that the test also passes if a local MongoDB ReplicaSet is used (via Docker), however I am unsure how this could be done with mongodb-memory-server or if that is even necessary.

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes

@diesieben07 diesieben07 changed the title fixes creation of related documents within a transaction if filterOptions is used fix: fixes creation of related documents within a transaction if filterOptions is used Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relationship field validation does not respect the current transaction

2 participants