From 496a5c19d11d6baacda37ce2ad80900cd29c69d6 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Mon, 1 Jun 2015 08:49:40 +0200 Subject: [PATCH] Raise an exception when trying to insert n-uples with the wrong cardinality --- relational/relation.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/relational/relation.py b/relational/relation.py index 60e9e9b..b0adb35 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -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()