On May 3, 2009, at 5:14 AM, Werner F. Bruhin wrote:
> > Michael Bayer wrote: >> You need to set allow_null_pks=true on your mapper. This will be on >> by default in 06. >> > I am running into the same problem, but I use declarative. > > After some search and looking at mapper.py I figured out I could do > this: > > db.Vcbook.__mapper__.allow_null_pks = True > > But I did not like using __mapper__, so nearly just asked but then > gave > the search option another go on the doc and found: > > __mapper_args__ = {'allow_null_pks': True} > > Now, if I would want to do this not in my model.py but just in the > code > section where I need this would using the "__mapper__" be the only way > to do this or is there a cleaner way, e.g. > > db.Vcbook.Getmapper().allow_null_pks = True or similar? you can make a mapper() decorator and pass it to your declarative base def mapper(*arg, **kw): kw['allow_null_pks'] = True return orm.mapper(*arg, **kw) Base = declarative_base(mapper=mapper) > > > Werner > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---