Skip to content

Commit

Permalink
fix: isinstance with self.document_class iso Document
Browse files Browse the repository at this point in the history
  • Loading branch information
F M authored and msiemens committed Oct 5, 2024
1 parent 9175dcb commit bc93aad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tinydb/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def insert(self, document: Mapping) -> int:
raise ValueError('Document is not a Mapping')

# First, we get the document ID for the new document
if isinstance(document, Document):
if isinstance(document, self.document_class):
# For a `Document` object we use the specified ID
doc_id = document.doc_id

Expand Down Expand Up @@ -190,7 +190,7 @@ def updater(table: dict):
if not isinstance(document, Mapping):
raise ValueError('Document is not a Mapping')

if isinstance(document, Document):
if isinstance(document, self.document_class):
# Check if document does not override an existing document
if document.doc_id in table:
raise ValueError(
Expand Down Expand Up @@ -521,7 +521,7 @@ def upsert(self, document: Mapping, cond: Optional[QueryLike] = None) -> List[in
"""

# Extract doc_id
if isinstance(document, Document) and hasattr(document, 'doc_id'):
if isinstance(document, self.document_class) and hasattr(document, 'doc_id'):
doc_ids: Optional[List[int]] = [document.doc_id]
else:
doc_ids = None
Expand Down

0 comments on commit bc93aad

Please sign in to comment.