Skip to content

Inconsistent results with non-existent doc_id #591

Closed

Description

@alesbukovsky

TinyDB version: 4.8.2
Python version: 3.13.3

There is a difference in behavior when a non-existent doc_id is passed:

  • table.get(doc_id=N) returns None
  • table.update(doc_ids=[N]) raises KeyError exception
  • table.remove(doc_ids=[N]) raises KeyError exception

All method should have consistent results, i.e., either all raising an exception, or all returning a value (None or an empty list).

Also, the KeyError is generally not mentioned in the documentation for these operations.

Activity

  1. changed the title [-]Inconsistent get() and remove() results with non-existent doc_id[/-] [+]Inconsistent results with non-existent doc_id[/+] on May 12, 2025
  2. msiemens commented on Dec 27, 2025

    @msiemens
    Owner

    You're right, this is not consistent at the moment. I'd be happy to accept pull requests for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributions-welcomeHappy to accept pull requests for this issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions