kwargs are ignored when creating an object
Issue #351
resolved
I'm pretty sure following used to work but not anymore. Is it an intentended change? If it is I hope the decision can be reversed.
meta = DynamicMetaData()
people = Table('people', meta,
Column('id', Integer, primary_key=True),
Column('fname', String(30)),
Column('lname', String(30)),
)
class Person(object): pass
mapper(Person, people)
kw = dict(fname='John', lname='Smith')
p1 = Person(**kw)
p2 = Person()
p2.fname = 'John'
p2.lname = 'Smith'
assert p1.fname == p2.fname
The workaround is just too ugly :-)
p1 = Person()
[k, v) for k,v in d.items()](setattr(p1,)
Comments (2)
-
repo owner -
Account Deleted Thanks for setting me straight. :-)
- Log in to comment
its too much of an assumption to make for SA to guess how youd like your object's constructor to function. SA's job is SQL generation, not class construction. you can get this behavior back if you use the assignmapper extension module:
(or just define a superclass for your objects with a one liner constructor....)