Explicitly compare IDs to None
Many database IDs (Resource, WatchRule) are integers, so 0 is a valid ID and evaluating it in a boolean context may give the wrong result for the first entry in the table. Even for the ones that aren't (e.g. Stack) it's better to explicitly compare to None. Change-Id: Id95eeb5cd0f9cac82937fae48122ce5fa90ca48d
This commit is contained in:
@@ -360,7 +360,7 @@ class Stack(collections.Mapping):
|
||||
return resources or None
|
||||
|
||||
def db_resource_get(self, name):
|
||||
if not self.id:
|
||||
if self.id is None:
|
||||
return None
|
||||
return self._db_resources_get().get(name)
|
||||
|
||||
@@ -461,7 +461,7 @@ class Stack(collections.Mapping):
|
||||
Includes nested stacks below.
|
||||
"""
|
||||
if not stack_id:
|
||||
if not self.id:
|
||||
if self.id is None:
|
||||
# We're not stored yet, so we don't have anything to count
|
||||
return 0
|
||||
stack_id = self.id
|
||||
@@ -653,7 +653,7 @@ class Stack(collections.Mapping):
|
||||
else:
|
||||
s['raw_template_id'] = self.t.id
|
||||
|
||||
if self.id:
|
||||
if self.id is not None:
|
||||
if exp_trvsl is None and not ignore_traversal_check:
|
||||
exp_trvsl = self.current_traversal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user