Browse Source

Added check against primary_key and uniq

As a primary_key field has to be unique, added a check at DataHandler
instanciation to make sure a field set as a pk is not set as non-unique
Quentin Bonaventure 8 years ago
parent
commit
819e9f62cf
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      lodel/leapi/datahandlers/base_classes.py

+ 6
- 0
lodel/leapi/datahandlers/base_classes.py View File

@@ -57,6 +57,9 @@ class DataHandler(object):
57 57
             del(kwargs['default'])
58 58
         for argname, argval in kwargs.items():
59 59
             setattr(self, argname, argval)
60
+            
61
+        if self.is_primary_key() and not self.is_uniq():
62
+            raise LodelException("'primary_key' field has to be uniq")
60 63
 
61 64
     ## Fieldtype name
62 65
     @classmethod
@@ -73,6 +76,9 @@ class DataHandler(object):
73 76
 
74 77
     def is_primary_key(self):
75 78
         return self.primary_key
79
+    
80
+    def is_uniq(self):
81
+        return self.uniq
76 82
 
77 83
     ##@brief checks if a fieldtype is internal
78 84
     # @return bool

Loading…
Cancel
Save