- changed title to Column.copy() with enum no longer sends create events
- edited description
Column.copy() with enum no longer sends create events
from sqlalchemy import *
from sqlalchemy.orm import *
m = MetaData()
y = Column('y', Enum('a', 'b', 'c', name='myenum'))
t = Table(
'x', m,
y.copy()
)
e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
c = e.connect()
t = c.begin()
m.create_all(c)
output:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "myenum" does not exist
LINE 3: y myenum
^
[SQL: '\nCREATE TABLE x (\n\ty myenum\n)\n\n']
this is a regression vs. 1.0 and in particular affects various declarative mechamisms such as mixins.
Comments (4)
-
repo owner -
repo owner regression in 80aeba3d5e0269eb689d991ca0b8e281715113ed due to
#3250adding a copy() mehod to the base TypeEngine stepping on that of SchemaType. -
repo owner -
repo owner - changed status to resolved
Add explicit copy() to Enum
The Boolean and Enum types both place SchemaType second in the inheritance hierarchy. In the case of Enum, this works out that the copy() method is called from the base TypeEngine which fails to transfer _create_events. The test suite doesn't seem to work with the inhertance hierarchy set up like this as the event listeners don't work out, the _on_metadata_create and _on_table_create hooks cause the production of an adapted type which then adds event listeners that cause deque changed while iteration. It's not clear why Enum /Boolean don't have this problem. But in any case it seems like the class mechanics for these types remains fragile and would benefit from yet another refactor someday.
Change-Id: Ib641a5d2321b00f58bbe98dd0c5e789374db32b2 Fixes:
#3827→ <<cset 8ef4f6a53864>>
- Log in to comment
I've had to rewrite the description here as it lacked a proper test case.