Skip to content

Conversation

@nickbrowne
Copy link
Contributor

@nickbrowne nickbrowne commented Oct 22, 2025

This change is temporary to give us an opportunity to clean up the data and fix the db constraints.

To test:

  1. Start postgres demo server: ./bin/demoserver-pg
  2. Create a new document:
curl -H 'Content-Type: application/json' -X PUT -d '{ "type": "text" }' http://localhost:8000/doc/testdoc
  1. Add some operations:
curl -H 'Content-Type: application/json' -X POST -d '[{"p": 0, "i": "ing"}]' http://localhost:8000/doc/testdoc?v=0
curl -H 'Content-Type: application/json' -X POST -d '[{"p": 0, "i": "test"}]' http://localhost:8000/doc/testdoc?v=1
  1. Attempt to create the document again:
curl -H 'Content-Type: application/json' -X PUT -d '{ "type": "text" }' http://localhost:8000/doc/testdoc

The expected behaviour is now that step 4 returns a 404 rather than inserting an empty snapshot at version 0.
You can verify with:

SELECT * FROM snapshots WHERE doc='testdoc';

On current master an empty snapshot is erroneously created when one already exists.

cursor[bot]

This comment was marked as outdated.

This change is temporary to give us an opportunity to clean up
the data and fix the db constraints.
@nickbrowne nickbrowne force-pushed the 20941-prevent-double-insertion-of-snapshots branch from 626dfdb to 18c3a84 Compare October 23, 2025 00:13
@nickbrowne nickbrowne changed the title [WIP] Guard against multiple snapshots inserted during PUT for given doc Guard against multiple snapshots inserted during PUT for given doc Oct 23, 2025
@nickbrowne nickbrowne merged commit 17e0883 into master Oct 23, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants