[oe-commits] [bitbake] 05/10: toaster: prevent exception when Project.release is null

git at git.openembedded.org git at git.openembedded.org
Tue Apr 19 20:13:40 UTC 2016


rpurdie pushed a commit to branch 1.30
in repository bitbake.

commit 6919a2b2e412a9e7b652a6bc191e7c1bed035222
Author: Elliot Smith <elliot.smith at intel.com>
AuthorDate: Tue Apr 19 17:28:42 2016 +0100

    toaster: prevent exception when Project.release is null
    
    Project.release can be null. This causes an exception when calling
    get_all_compatible_layer_versions(), as the query to fetch
    the layer versions references release.branch_name.
    
    Add a guard to the function so that an empty queryset is returned
    if the release isn't set for a project.
    
    Signed-off-by: Elliot Smith <elliot.smith at intel.com>
    Signed-off-by: Michael Wood <michael.g.wood at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/toaster/orm/models.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 68c3072..f0a8786 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -264,11 +264,17 @@ class Project(models.Model):
     def get_all_compatible_layer_versions(self):
         """ Returns Queryset of all Layer_Versions which are compatible with
         this project"""
-        queryset = Layer_Version.objects.filter(
-            (Q(up_branch__name=self.release.branch_name) &
-             Q(build=None) &
-             Q(project=None)) |
-             Q(project=self))
+        queryset = None
+
+        # guard on release, as it can be null
+        if self.release:
+            queryset = Layer_Version.objects.filter(
+                (Q(up_branch__name=self.release.branch_name) &
+                 Q(build=None) &
+                 Q(project=None)) |
+                 Q(project=self))
+        else:
+            queryset = Layer_Version.objects.none()
 
         return queryset
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list