On Jul 29, 2010, at 11:08 PM, Russell Warren wrote: > I've got a bunch of old sqlalchemy code using the declarative > framework where the default field values could be assigned after the > initial definition, as in this reduced example: > > ####### > > from sqlalchemy import * > from sqlalchemy.ext.declarative import declarative_base > from sqlalchemy.orm import relation, sessionmaker > > Base = declarative_base() > > class Bogus(Base): > __tablename__ = 'bogus' > > pk = Column(Integer, primary_key=True) > c1 = Column(Integer) > c1.default = 2000 ## NOW A PROBLEM ## > > engine = create_engine("sqlite://", echo = True) > Base.metadata.create_all(engine) > > ####### > > Now this code crashes on the create_all() call inside visitors.py's > traverse_using() call, with: > > AttributeError: 'int' object has no attribute '__visit_name__'
use default=ColumnDefault(2000). > > If I move the default assignments into the column constructor with the > "default=" kwarg (as is proper according to current docs), it works > fine. > > Is there a clean/functional/safe way to assign defaults _after_ the > first assignment? The old code collected together all the default > assignments in one spot to cut down on the size of the (large) table > definition code and improve readability of the code... it would be > great to keep it that way. > > I'm using sqla 0.6.3 now. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@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. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.