Creating an anonymous CTE with an Update causes AttributeError
Issue #3744
resolved
Test case:
class Foo(Base):
__tablename__ = "foo"
id = Column(Integer, primary_key=True)
foo = Foo.__table__
q = foo.update().returning(foo.c.id).cte()
Stack trace:
Traceback (most recent call last):
File "sqlite.py", line 32, in <module>
main()
File "sqlite.py", line 28, in main
q = foo.update().returning(foo.c.id).cte()
File "/home/jack/dev/sqlalchemy/lib/sqlalchemy/sql/selectable.py", line 1588, in cte
return CTE(self, name=name, recursive=recursive)
File "/home/jack/dev/sqlalchemy/lib/sqlalchemy/sql/selectable.py", line 1386, in __init__
super(CTE, self).__init__(selectable, name=name)
File "/home/jack/dev/sqlalchemy/lib/sqlalchemy/sql/selectable.py", line 1235, in __init__
if self.original.named_with_column:
AttributeError: 'Update' object has no attribute 'named_with_column'
Comments (2)
-
repo owner -
repo owner - changed status to resolved
Ensure DML provides named_with_column for CTE(Alias)
Fixed bug in new CTE feature for update/insert/delete whereby an anoymous (e.g. no name passed) :class:
.CTE
construct around the statement would fail. The Alias base class of CTE checks for the "named_with_column" attribute in order to detect if the underlying selectable has a name; UpdateBase now provides this as False.Change-Id: I4b0309db21379a4c0cb93085298c86da3cf840e4 Fixes:
#3744→ <<cset 889c011a0f7b>>
- Log in to comment