fixed up some of the error messages tailored
in [ticket:2069]
+- sql
+ - Added explicit check for when Column .name
+ is assigned as blank string [ticket:2140]
+
- postgresql
- Fixed the psycopg2_version parsing in the
psycopg2 dialect.
def setup_query(self, context, entity, path, reduced_path, adapter,
column_collection=None, **kwargs):
+# import pdb
+# pdb.set_trace()
for c in self.columns:
if adapter:
c = adapter.columns[c]
["%s=%s" % (k, repr(getattr(self, k))) for k in kwarg])
def _set_parent(self, table):
- if self.name is None:
+ if not self.name:
raise exc.ArgumentError(
- "Column must be constructed with a name or assign .name "
- "before adding to a Table.")
+ "Column must be constructed with a non-blank name or "
+ "assign a non-blank .name before adding to a Table.")
if self.key is None:
self.key = self.name
if getattr(self, 'table', None) is not None:
- raise exc.ArgumentError("this Column already has a table!")
+ raise exc.ArgumentError(
+ "Column object already assigned to Table '%s'" %
+ self.table.description)
if self.key in table._columns:
col = table._columns.get(self.key)
for i, col in enumerate(tbl.c):
assert col.name == c[i].name
- def test_incomplete(self):
- c = self.columns()
+ def test_name_none(self):
+
+ c = Column(Integer)
+ assert_raises_message(
+ exc.ArgumentError,
+ "Column must be constructed with a non-blank name or assign a "
+ "non-blank .name ",
+ Table, 't', MetaData(), c)
+
+ def test_name_blank(self):
- assert_raises(exc.ArgumentError, Table, 't', MetaData(), *c)
+ c = Column('', Integer)
+ assert_raises_message(
+ exc.ArgumentError,
+ "Column must be constructed with a non-blank name or assign a "
+ "non-blank .name ",
+ Table, 't', MetaData(), c)
+
+ def test_dupe_column(self):
+ c = Column('x', Integer)
+ t = Table('t', MetaData(), c)
+
+ assert_raises_message(
+ exc.ArgumentError,
+ "Column object already assigned to Table 't'",
+ Table, 'q', MetaData(), c)
def test_incomplete_key(self):
c = Column(Integer)