Regression: Date takes no parameters

Issue #3446 resolved
Thomas Beiganz created an issue

In Version 0.8.3 you could format Date with storage_format

 Date(storage_format="%(day)02d.%(month)02d.%(year)04d")

In 1.0.5 this is no longer possible

    Column('timestamp', Date(storage_format="%(day)02d.%(month)02d.%(year)04d"), primary_key=True),
TypeError: object() takes no parameters

Comments (4)

  1. Mike Bayer repo owner

    that code doesn't work - the argument you are passing in 0.8.3 is ignored entirely. In the 0.9 series, this was fixed so as not to be misleading. If you want a sqlite date with a storage format you need to use the sqlite.DATE type. Notice below, running this script against any 0.8 version, that the storage_format under 0.8.3 is gone with a regular date:

    from sqlalchemy.dialects import sqlite
    from sqlalchemy import Date
    
    
    d = Date(storage_format="%(day)02d.%(month)02d.%(year)04d")
    print(d.__dict__)
    
    d = sqlite.DATE(storage_format="%(day)02d.%(month)02d.%(year)04d")
    print(d.__dict__)
    
    #!
    
    $ python -W always::DeprecationWarning ~/dev/sqlalchemy/test.py
    /Users/classic/dev/sqlalchemy/test.py:5: SADeprecationWarning: Passing arguments to type object constructor <class 'sqlalchemy.types.Date'> is deprecated
      d = Date(storage_format="%(day)02d.%(month)02d.%(year)04d")
    {}
    {'_storage_format': '%(day)02d.%(month)02d.%(year)04d'}
    classics-MacBook-Pro:sa083 classic$ 
    

    we made the mistake here of only putting a deprecation warning on that which you can see above, which is a mistake because nobody runs Python with the -W flag, and also this wasn't mentioned in the 0.9 migration notes, because again, it was such an old and ignored thing which didn't even work that we didn't think anyone was doing it, but a bunch of people hit it. I should probably put a note in the 0.9 migration notes. thanks for reporting, we should probably reach out to folks still on 0.8 for this one.

  2. Log in to comment