I can't use YEAR column type with sqlalchemy/databases/mysql.py

37 views
Skip to first unread message

hiroshiykw

unread,
Aug 8, 2007, 4:55:48 AM8/8/07
to sqlalchemy
Hi.
In SQLAlchemy 0.3.10 ( / Python2.5), I found that YEAR column type is
created as TEXT column type in the following simple create query:
-------------------------------------------
from sqlalchemy import *
from sqlalchemy.databases.mysql import *
db = create_engine("mysql://root@localhost/test")
metadata = MetaData(db)
year_table = Table("year_table", metadata,
Column("y", MSYear)
)
year_table.create()
--------------------------------------------

I read the source and find it seems MSYear's get_search_list() method
returns a sequence of (TEXT, MSYear, String, TypeEngine,
AbstractType).In this case, the first item, Text, is used.

I'm not familiar with the SQLAlchemy's whole archtecture, so now I'm
avoiding this problem adding get_search_list() method in MSYear like
this:
------------------------------------------
class MSYear(sqltypes.String):
"""MySQL YEAR type, for single byte storage of years 1901-2155"""

def get_col_spec(self):
if self.length is None:
return "YEAR"
else:
return "YEAR(%d)" % self.length

def get_search_list(self):
return [self.__class__]
------------------------------------------
I think this should be fixed in proper manner.

Regards,

Hiroshi Ayukawa

jason kirtland

unread,
Aug 9, 2007, 3:29:41 PM8/9/07
to sqlal...@googlegroups.com
hiroshiykw wrote:
>
> Hi.
> In SQLAlchemy 0.3.10 ( / Python2.5), I found that YEAR column
> type is created as TEXT column type in the following
> [...]

Sorry about that. This is now fixed in the trunk for 0.4 and in
the 0.3 maintenance branch.

Cheers,
Jason

Reply all
Reply to author
Forward
0 new messages