- changed status to resolved
CompileError with column named "<tablename>_<id>"
Issue #1755
resolved
I've confirmed this works as expected on 0.5.8, however it is broken on in (at least) 0.6beta2 and 0.6beta3.
Naming a column within a table as {{{<table>_<id>}}} causes SQLAlchemy to fail when attempting to update the object. I've attached a script using a SQLite memory database that can replicate the issue.
Example:
class Book(Base):
__tablename__ = 'book'
id = Column(Integer, primary_key=True)
book_id = Column(String(36), unique=True, nullable=False)
title = Column(String(128), nullable=False)
s = Session()
book = Book(book_id=str(uuid4()), title='1984')
s.add(book)
s.commit()
book.title = 'Brave New World'
s.commit()
This will provide the following traceback on the 2nd commit:
...
File "/Users/michael/virtualenv/paste/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/engine/base.py", line 676, in process
return obj._compiler_dispatch(self, **kwargs)
File "/Users/michael/virtualenv/paste/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/sql/visitors.py", line 47, in _compiler_dispatch
return getter(visitor)(self, **kw)
File "/Users/michael/virtualenv/paste/lib/python2.6/site-packages/SQLAlchemy-0.6beta3-py2.6.egg/sqlalchemy/sql/compiler.py", line 553, in visit_bindparam
% bindparam.key
sqlalchemy.exc.CompileError: Bind parameter name 'book_id' is reserved for the VALUES or SET clause of this insert/update statement.
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
thanks for finding this, it was behavior removed in 0.6 as it wasn't covered in 0.5 and I couldn't recall how to get that behavior covered (i.e. to fail when missing). It's only the ORM's usage of column._label that produces this. 5c758932a512e281308d2e1c147e18ed4eddc6b0