On Oct 11, 2008, at 8:40 PM, Julian Yap wrote:
> > Hi All, > > According to this change set --> http://www.sqlalchemy.org/trac/changeset/5054 > The 'length' argument to all Numeric types has been renamed to > 'scale'. 'length' is deprecated and is still accepted with a warning. > > On my workstation, I have SQLAlchemy 0.5.0rc1 whereas on some servers > I have 0.4.7p1 (due to Python 2.3). > > Running a script on my workstation spits out the deprecation warnings. > > What would be the best way to re-write my script so it's backwards > compatible to 0.4.x and doesn't spit out the deprecation warnings in > 0.5.x? > > Here's an example line: > model.py:54: SADeprecationWarning: 'length' is deprecated for > Numeric. Use 'scale'. > schema.Column('balance', types.Numeric(precision=20, length=6), > nullable=False, default=0.000000), > > I'm thinking perhaps a try block at the start of my model.py script > which tests for the SQLAlchemy version? Two ways to do this. One is to make a wrapper function around Numeric which does the right thing based on SQLAlchemy version, i.e. def Numeric(**kwargs): if SQLALCHEMY_4: kwargs['scale'] = kwargs.pop('length', None) return types.Numeric(**kwargs) The other is just to use the warnings filter to suppress the warning, as described in http://www.python.org/doc/2.4.2/lib/warning- filter.html . --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---