Commit 625488fa authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

added some error checks

parent 24a4e14d
......@@ -77,6 +77,8 @@ class DBContext:
self.target_att = postdata.get('target_att%s' % widget_id)[0]
self.target_att_val = postdata.get('target_att_val%s' % widget_id)[0]
self.tables = postdata.get('tables%s' % widget_id, [])
if self.target_table not in self.tables:
raise Exception('The selected target table "%s" is not among the selected tables.' % self.target_table)
# Propagate the selected tables
for table in self.cols.keys():
if table not in self.tables:
......@@ -87,6 +89,8 @@ class DBContext:
del self.connected[pair]
for table in self.tables:
self.cols[table] = postdata.get('%s_columns%s' % (table, widget_id), [])
if table == self.target_table and self.target_att not in self.cols[table]:
raise Exception('The selected target attribute ("%s") is not among the columns selected for the target table ("%s").' % (self.target_att, self.target_table))
def __repr__(self):
return str((self.target_table, self.target_att, self.tables, self.cols, self.connected))
Supports Markdown
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