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

This commit is contained in:
Salvo 'LtWorf' Tomaselli 2015-06-01 08:49:40 +02:00
parent 3fca4edd15
commit 496a5c19d1

View File

@ -468,9 +468,14 @@ class relation (object):
This function will not insert duplicate tuples. This function will not insert duplicate tuples.
All the values will be converted in string. All the values will be converted in string.
Will return the number of inserted rows.''' Will return the number of inserted rows.'''
# Returns if tuple doesn't fit the number of attributes
if len(self.header.attributes) != len(values): 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() self._make_writable()