Ver código fonte

fixed setting of the label in the result creation

Dimitri Korsch 3 anos atrás
pai
commit
0066240ed1
1 arquivos alterados com 4 adições e 6 exclusões
  1. 4 6
      pycs/database/File.py

+ 4 - 6
pycs/database/File.py

@@ -145,13 +145,11 @@ class File(NamedBaseModel):
                             data=data)
 
         if label is not None:
-            if isinstance(label, int):
-                label = Label.query.get(label)
+            assert isinstance(label, (int, Label)), f"Wrong label type: {type(label)}"
+            if isinstance(label, Label):
+                label = label.id
 
-            elif not isinstance(label, Label):
-                raise ValueError(f"wrong label type: {type(label)}")
-
-            result.label = label
+            result.label_id = label
 
         self.commit()
         return result