diff --git a/dataset/persistence/table.py b/dataset/persistence/table.py index 0e2b84c..57d43a1 100644 --- a/dataset/persistence/table.py +++ b/dataset/persistence/table.py @@ -219,6 +219,11 @@ class Table(object): """ self._check_dropped() self.database._acquire() + + # check that column name is OK: + if '.' in name: + raise ValueError("Invalid column name: %r" % name) + try: if name not in self.table.columns.keys(): self.database.op.add_column( diff --git a/test/test_persistence.py b/test/test_persistence.py index efc3b87..ef570dd 100644 --- a/test/test_persistence.py +++ b/test/test_persistence.py @@ -192,6 +192,15 @@ class TableTestCase(unittest.TestCase): row['foo'] = 'bar' self.tbl.update(row, ['place', 'date']) + def test_weird_column_names(self): + with self.assertRaises(ValueError): + self.tbl.insert({ + 'date': datetime(2011, 1, 2), + 'temperature': -10, + 'foo.bar': 'Berlin', + 'qux.bar': 'Huhu' + }) + def test_delete(self): self.tbl.insert({ 'date': datetime(2011, 1, 2),