-
Notifications
You must be signed in to change notification settings - Fork 54
feat: Add preserveSequence flag for upserts #792
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
feat: Add preserveSequence flag for upserts #792
Conversation
- Add preserveSequence property to Database class - Add getPreserveSequence(), setPreserveSequence(), withPreserveSequence() methods - Conditionally remove $sequence in upsertDocuments based on flag - Add testPreserveSequenceUpsert test in GeneralTests.php
📝 WalkthroughWalkthroughThe changes introduce a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/e2e/Adapter/Scopes/GeneralTests.php`:
- Around line 305-314: The test currently only guards using
getSupportForUpserts(), but then calls createAttribute() which will fail on
schemaless adapters; update the guard to also check the adapter's attribute
support (e.g., call getAdapter()->getSupportForAttributes() or equivalent) and
if attributes aren't supported call $this->expectNotToPerformAssertions() and
return before invoking createAttribute(); ensure the new check is placed before
createAttribute() and references the existing getSupportForUpserts(),
createCollection(), and createAttribute() symbols so the test skips for adapters
that support upserts but not attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/e2e/Adapter/Scopes/DocumentTests.php`:
- Around line 1218-1237: The test uses an invalid literal sequence 999 which can
fail UUID7 adapters; change the upsert payload in the ignored-branch to supply a
valid sequence value (e.g., reuse $originalSeq1 or $originalSeq2) instead of 999
so validation passes even though setPreserveSequence(false) should ignore it;
update the Document creation passed to Database::upsertDocuments (the new
Document([... '$sequence' => ...])) to use the captured
$originalSeq1/$originalSeq2 while keeping the rest of the assertions intact.
- Around line 1225-1290: The test mutates the shared preserveSequence flag via
Database::setPreserveSequence() and leaves it false, risking cross-test state
bleed; modify the test to capture the prior state by calling $previous =
$database->getPreserveSequence() before changing it, wrap the operations that
change the flag (setPreserveSequence, withPreserveSequence, upsertDocuments,
deleteCollection) in a try/finally, and in the finally restore the original
value via $database->setPreserveSequence($previous) so the flag is always reset
even on assertion failures.
b091840 to
b0586bd
Compare
- Add setPreserveSequence delegation to Mirror.php - Add test case for invalid $sequence value throwing StructureException
faf92c8 to
cf11809
Compare
Notes
$sequencevalues are validated and throw aStructureException$sequencetype validation is delegated to the database itself rather than being enforced at the application level