Re: [Sqlalchemy-tickets] [sqlalchemy] #2748: reflecttable not checking for None exclude_columns
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-06-07 23:54:19
|
#2748: reflecttable not checking for None exclude_columns
-------------------------------------------+-------------------------------
Reporter: rstuart4133 | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: schema | Severity: minor - half an
Resolution: | hour
Progress State: needs questions answered | Keywords:
-------------------------------------------+-------------------------------
Comment (by rstuart4133):
> Are you using it directly
No. This is all I have to do to reproduce the bug:
{{{
$ python
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Debug helper loaded. Type "print D.__doc__" for help.
>>> import sqlalchemy
>>> conn =
sqlalchemy.create_engine("firebird://ro:ro@10.7.0.3/lubenet/mobile.gdb").connect()>>>
metatable = sqlalchemy.MetaData(conn)
>>> est = sqlalchemy.Table("estline", metatable)
>>> conn.engine.reflecttable(est)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <lambda>
File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/deprecations.py",
line 100, in warned
return fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line
2533, in reflecttable
self.dialect.reflecttable(conn, table, include_columns)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py",
line 260, in reflecttable
return insp.reflecttable(table, include_columns, exclude_columns)
File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/reflection.py",
line 419, in reflecttable
if pk in table.c and pk not in exclude_columns
TypeError: argument of type 'NoneType' is not iterable
>>> sqlalchemy.__version__
'0.7.8'
>>>
}}}
> or is there some codepath that it becomes None?
Yes, there is. It is the one you see in the backtrace. I'll spell it out
for you, using the line numbers from rel_0_7 in github:
* I call sqlalchemy/engine/base.py:2516 `Engine.reflecttable()`
* On line 2532 it calls sqlalchemy/engine/default.py:258
`DefaultDialect.reflecttable(..., exclude_columns=None)`
* On line 260 it calls sqlalchemy/engine/reflection.py:258
`Inspector.reflecttable()`, passing `None` for `exclude_columns`.
* On line 419, it does not modify `pk not in exclude_columns`, and
execute `pk not in exclude_columns`.
* Thus `TypeError` is raised.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2748#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|