reflection does not add the names to the constraints
From forum discussion: http://groups.google.com/group/sqlalchemy/t/644805aa7b61df5c
if I reflect the tables in existing db where constraints are all named and then try: from sqlalchemy.schema import DropConstraint for table in metadata.tables.keys(): for con in metadata.tablestable.constraints: if isinstance(con, PrimaryKeyConstraint): engine.execute(DropConstraint(con))
I get this exception: engine.execute(DropConstraint(con)) File "/usr/lib/python2.5/site-packages/sqlalchemy/engine/base.py", line 1533, in execute return connection.execute(statement, multiparams, params) File "/usr/lib/python2.5/site-packages/sqlalchemy/engine/base.py", line 1086, in execute return Connection.executorsc(self, object, multiparams, params) File "/usr/lib/python2.5/site-packages/sqlalchemy/engine/base.py", line 1133, in _execute_ddl compiled_ddl=ddl.compile(dialect=self.dialect), File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/ expression.py", line 1257, in compile compiler.compile() File "/usr/lib/python2.5/site-packages/sqlalchemy/engine/base.py", line 663, in compile self.string = self.process(self.statement) File "/usr/lib/python2.5/site-packages/sqlalchemy/engine/base.py", line 676, in process return obj._compiler_dispatch(self, kwargs) File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/visitors.py", line 47, in _compiler_dispatch return getter(visitor)(self, *kw) File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/compiler.py", line 1209, in visit_drop_constraint self.preparer.format_constraint(drop.element), File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/compiler.py", line 1550, in format_constraint return self.quote(constraint.name, constraint.quote) File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/compiler.py", line 1524, in quote if self._requires_quotes(ident): File "/usr/lib/python2.5/site-packages/sqlalchemy/sql/compiler.py", line 1505, in _requires_quotes lc_value = value.lower() AttributeError: 'NoneType' object has no attribute 'lower'
It does not look like the reflection is applying the names on the constraints which causes the exception.
Test script attached.
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
82d194c9a65b09fef8d52318cbe38e2c84dfd2ca