DeclarativeReflection example doesn't accept overrides
I tried to use the declarative feflection example against a view; but that wouldn't work as the ORM needs a primary key. Trying to override didn't work; the fix is simple: pass in *[ _ for _ in table.c ]
to the Table
constructor during DeclarativeReflectedBase.prepare()
.
I've added the DeclarativeReflectedBase
class to the ext.declarative module and added a test to confirm the override isn't overriding. Then I've confirmed the fix clears the error below. I've made a pull-request of these changes.
I'd like guidance at this point: should I keep making DeclarativeReflectedBase
a real part of the library, with real docs and tests? Or should I just patch the examples and be done with it?
ERROR: test.ext.test_declarative.ReflectionTest.test_override_declarative_reflection
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/lbruno/sqlalchemy/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/lbruno/sqlalchemy/./test/ext/test_declarative.py", line 3585, in test_override_declarative_reflection
Base.prepare(self.engine)
File "/home/lbruno/sqlalchemy/./lib/sqlalchemy/ext/declarative.py", line 1683, in prepare
klass.__mapper__ = mapper(*args, **kw)
File "/home/lbruno/sqlalchemy/./lib/sqlalchemy/orm/__init__.py", line 1116, in mapper
return Mapper(class_, local_table, *args, **params)
File "/home/lbruno/sqlalchemy/./lib/sqlalchemy/orm/mapper.py", line 203, in __init__
self._configure_pks()
File "/home/lbruno/sqlalchemy/./lib/sqlalchemy/orm/mapper.py", line 766, in _configure_pks
(self, self.mapped_table.description))
ArgumentError: Mapper Mapper|Override|sqla_test__no_pkey could not assemble any primary key columns for mapped table 'sqla_test__no_pkey'
Comments (4)
-
repo owner -
Account Deleted Yeah, I'll try to do it tonight. Thanks!
-
repo owner - changed status to resolved
the patch was ready to go so I committed the reflection fix in 345de2ee1dfb12c6314144c2b7ed6fb4a7a3cb7c . If/when we add declarativereflectivebase to the ORM's official API can be a separate thing.
-
repo owner - removed milestone
Removing milestone: 0.7.6 (automated comment)
- Log in to comment
the bug is in the new autoload_replace functionality. A patch is attached. Do you want to work it into your pull request ?