Commit 5bf3b08f authored by Vincent Pelletier's avatar Vincent Pelletier

CMFActivity.Activity.SQLBase: Fix handling of malformed multi-column dependencies.

Fixes the handling of:
- non-sequence dependency_value
- incorrect dependency_value length
- None in dependency_value
- None in dependency_value items
parent 7f894075
...@@ -452,7 +452,8 @@ CREATE TABLE %s ( ...@@ -452,7 +452,8 @@ CREATE TABLE %s (
# Convert every form into its vector equivalent form, ignoring # Convert every form into its vector equivalent form, ignoring
# conditions which cannot match any activity, and (for n-valued) # conditions which cannot match any activity, and (for n-valued)
# enumerate all possible combinations for later reverse-lookup. # enumerate all possible combinations for later reverse-lookup.
if len(column_list) == 1: column_count = len(column_list)
if column_count == 1:
dependency_value_list = [ dependency_value_list = [
x x
for x in ( for x in (
...@@ -467,19 +468,28 @@ CREATE TABLE %s ( ...@@ -467,19 +468,28 @@ CREATE TABLE %s (
if x is not None if x is not None
] ]
else: else:
try:
if (
len(dependency_value) != column_count or
None in dependency_value
):
# Malformed or impossible to match dependency, ignore.
continue
except TypeError:
# Malformed dependency, ignore.
continue
# Note: it any resulting item ends up empty (ex: it only contained # Note: it any resulting item ends up empty (ex: it only contained
# None), product will return an empty list. # None), product will return an empty list.
dependency_value_list = list(product(*( dependency_value_list = list(product(*(
( (
(x, ) (dependency_column_value, )
if isinstance( if isinstance(
dependency_column_value, dependency_column_value,
_SQLTEST_NON_SEQUENCE_TYPE_SET, _SQLTEST_NON_SEQUENCE_TYPE_SET,
) else ) else
x (x for x in dependency_column_value if x is not None)
) )
for x in dependency_value for dependency_column_value in dependency_value
if x is not None
))) )))
if not dependency_value_list: if not dependency_value_list:
continue continue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment