in 2.0 the ColumnCollectionConstraint will use a
"read only" column collection, renamed from "immutable".
Add logic to detect both of these kinds of collections
Change-Id: I4049c3081a2b3801ea7bfa31bb62bafb3eae4a9d
# same object that's present
assert column.key is not None
to_remove = collection[column.key]
- collection.remove(to_remove)
+
+ # SQLAlchemy 2.0 will use more ReadOnlyColumnCollection
+ # (renamed from ImmutableColumnCollection)
+ if hasattr(collection, "_immutable") or hasattr(collection, "_readonly"):
+ collection._parent.remove(to_remove)
+ else:
+ collection.remove(to_remove)
def _textual_index_column(