Raise an exception when trying to insert n-uples with the wrong cardinality

master
Salvo 'LtWorf' Tomaselli 2015-06-01 08:49:40 +07:00
parent 3fca4edd15
commit 496a5c19d1
1 changed files with 7 additions and 2 deletions

@ -468,9 +468,14 @@ class relation (object):
This function will not insert duplicate tuples.
All the values will be converted in string.
Will return the number of inserted rows.'''
# Returns if tuple doesn't fit the number of attributes
if len(self.header.attributes) != len(values):
return 0
raise Exception(
'Tuple has the wrong size. Expected %d, got %d' % (
len(self.header.attributes),
len(values)
)
)
self._make_writable()