Skip to content
This repository
Browse code

Adding a convenience method for getting the pk name so as not to expose

internals
  • Loading branch information...
commit 023d481199d6cea7d1ca223e3e46535496a81368 1 parent 04dace3
Charles Leifer authored August 01, 2012

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. 7  peewee.py
7  peewee.py
@@ -2740,8 +2740,8 @@ def get_or_create(cls, **query):
2740 2740
     def get(cls, *args, **kwargs):
2741 2741
         return cls.select().get(*args, **kwargs)
2742 2742
 
2743  
-    def get_pk_dict(self):
2744  
-        return {self._meta.pk_name: self.get_pk()}
  2743
+    def get_pk_name(self):
  2744
+        return self._meta.pk_name
2745 2745
 
2746 2746
     def get_pk(self):
2747 2747
         return getattr(self, self._meta.pk_name, None)
@@ -2750,6 +2750,9 @@ def set_pk(self, pk):
2750 2750
         pk_field = self._meta.fields[self._meta.pk_name]
2751 2751
         setattr(self, self._meta.pk_name, pk_field.python_value(pk))
2752 2752
 
  2753
+    def get_pk_dict(self):
  2754
+        return {self.get_pk_name(): self.get_pk()}
  2755
+
2753 2756
     def save(self, force_insert=False):
2754 2757
         field_dict = self.get_field_dict()
2755 2758
         if self.get_pk() and not force_insert:

0 notes on commit 023d481

Please sign in to comment.
Something went wrong with that request. Please try again.