Skip to content

Commit

Permalink
Fix: prevent errors when trying to get a PK from a not yet saved model
Browse files Browse the repository at this point in the history
  • Loading branch information
maximebf committed Sep 2, 2024
1 parent 3eca767 commit ffb5b43
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlorm/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def get_primary_key(self, obj):
pk = []
for col in self.columns:
if col.primary_key:
if not hasattr(obj, col.attribute):
return
pk.append(getattr(obj, col.attribute))
if len(pk) > 1:
return pk
Expand Down

0 comments on commit ffb5b43

Please sign in to comment.