[Sqlalchemy-tickets] Issue #3449: automap_base fails on my database (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
|
From: yoch <iss...@bi...> - 2015-06-11 19:43:30
|
New issue 3449: automap_base fails on my database https://bitbucket.org/zzzeek/sqlalchemy/issue/3449/automap_base-fails-on-my-database yoch: Hi, I use 1.0.5 version, but this bug occurs also with 0.9.8. Here a simple test-case to reproduce the bug : ``` #!SQL CREATE TABLE `hardware` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `hdw_type` varchar(15) NOT NULL, PRIMARY KEY (`id`), KEY `hdw_type` (`hdw_type`), CONSTRAINT `hardware_ibfk_1` FOREIGN KEY (`hdw_type`) REFERENCES `hdw_type` (`type`) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE IF NOT EXISTS `hdw_type` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` VARCHAR(15) NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `hdw_type_UNIQUE` (`type` ASC) ); ``` This simple code snippet fail : ``` #!python Base = automap_base() Base.prepare(engine, reflect=True) ``` Traceback : ``` #!console Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/automap.py", line 795, in prepare map_config.map() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 593, in map return super(_DeferredMapperConfig, self).map() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/base.py", line 530, in map **self.mapper_args File "<string>", line 2, in mapper File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 627, in __init__ self._configure_properties() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 1318, in _configure_properties setparent=True) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 1525, in _configure_property prop = self._property_from_column(key, prop) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 1693, in _property_from_column (key, self, column.key, prop)) sqlalchemy.exc.ArgumentError: WARNING: when configuring property 'hdw_type' on Mapper|hardware|hardware, column 'hdw_type' conflicts with property '<RelationshipProperty at 0xfc0bb0; hdw_type>'. To resolve this, map the column to the class under a different name in the 'properties' dictionary. Or, to remove all awareness of the column entirely (including its availability as a foreign key), use the 'include_properties' or 'exclude_properties' mapper arguments to control specifically which table columns get mapped. ``` I think this is related to my columns/indexes naming. Thank you |