- attached 3604.patch
auto-key-validation in mappedcollection bulk set is inconsistent vs. single item set
Issue #3604
new
e.g. make setitem and set symmetric; if users want validation that would be a separate event. partial patch forthcoming
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.collections import attribute_mapped_collection
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
bs = relationship("B", collection_class=attribute_mapped_collection("key"))
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
key = Column(String)
a_id = Column(ForeignKey('a.id'))
def __repr__(self):
return "B(%s)" % id(self)
a1 = A()
b1 = B(key='foo')
b2 = B(key='foo')
a1.bs['foo'] = b1
a1.bs['bar'] = b2
print a1.bs
a1 = A()
a1.bs = {"foo": b1, "bar": b2}
print a1.bs
Comments (4)
-
reporter -
reporter -
reporter - changed milestone to 1.3
- edited description
this is a subtle issue not making much impact, moving out
-
reporter - changed title to auto-key-validation in mappedcollection bulk set is inconsistent vs. single item set
- marked as bug
- Log in to comment