raise better error when non-executable passed to execute()
I don't think I had this issue previously, but I have noticed since using:
python: 3.5.2 sqlalchemy: 1.0.13
I run into the error doing the following:
table = sa.Table('foobar', sa.MetaData(), sa.Column('foo', sa.CHAR(7), primary_key=True)
engine.execute(table)
Traceback (most recent call last):
engine.execute(table)
File "/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1991, in execute
return connection.execute(statement, *multiparams, **params)
File "/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/anaconda/lib/python3.5/site-packages/sqlalchemy/sql/schema.py", line 65, in _execute_on_connection
return connection._execute_default(self, multiparams, params)
File "/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 942, in _execute_default
ret = ctx._exec_default(default, None)
File "/anaconda/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 952, in _exec_default
if default.is_sequence:
AttributeError: 'Table' object has no attribute 'is_sequence'
In[80]: table.create(engine)
The ddl statement does execute when I run:
engine.create(table)
Comments (5)
-
repo owner -
repo owner - changed milestone to 1.1
- changed title to raise better error when non-executable passed to execute()
there's some inconsistency here overall, some objects raise ArgumentError, but too late so it gets wrapped in DBAPIError (why not StatementError?!), target at 1.1.
-
repo owner -
reporter Awesome, thanks. Thought it could be invalid. Appreciate the more director exception.
-
repo owner - changed status to resolved
Check for supports_execution at ClauseElement base
Raise a more descriptive exception / message when ClauseElement or non-SQLAlchemy objects that are not "executable" are erroneously passed to
.execute()
; a new exception ObjectNotExecutableError is raised consistently in all cases.Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4 Fixes:
#3786→ <<cset c7b9c84312b6>>
- Log in to comment
engine.execute(table)
is not a valid API call. the error handling seems to be thrown off a little bit, that's all.