Skip to content

docs: explain moving documents between databases - #622

Merged
msiemens merged 2 commits into
msiemens:masterfrom
uadhran:docs/354-move-documents
Aug 10, 2026
Merged

docs: explain moving documents between databases#622
msiemens merged 2 commits into
msiemens:masterfrom
uadhran:docs/354-move-documents

Conversation

@uadhran

@uadhran uadhran commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Documents returned from TinyDB are Document wrappers that retain their
doc_id. Inserting them into another table or database reuses that ID and
can raise ValueError if the target already has that ID.

This documents the dict(document) workaround described by the maintainer
in #354.

Changes

  • Add Moving documents between databases section to docs/usage.rst
  • Add test_move_document_between_tables covering the doc_id conflict and fix

Verification

  • uv run py.test -v --cov=tinydb — 218 passed
  • uv run py.test -v --pycodestyle — not run (pre-existing failures on master)

Related: #354

@msiemens

msiemens commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR, @uadhran! Could you rebase this on the latest master so we can see what the CI pipeline says?

Document that Document instances retain their doc_id when inserted into
another table or database, and show the dict(document) workaround from
issue msiemens#354.

Add test_move_document_between_tables to cover the conflict and fix.

Related: msiemens#354
@uadhran
uadhran force-pushed the docs/354-move-documents branch from d55b7cf to 4a5a77c Compare August 10, 2026 05:33
@uadhran

uadhran commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest master so CI can run. Conflict with the merged #621 test was resolved by keeping both tests.

Table.get returns Document | None; narrow the type so mypy accepts
insert/dict(document) on Python 3.14 CI.
@msiemens

Copy link
Copy Markdown
Owner

Thanks!

@msiemens
msiemens merged commit 4aa5311 into msiemens:master Aug 10, 2026
31 checks passed
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.

2 participants