Here is a test case that fails with the sqlalchemy-trunk. Create 2 files, in the first:

import mx.DateTime as mxDateTime
from sqlalchemy import *

e = create_engine("postgres://database=test", echo=True)

test = Table("test", e,
  Column("id", String, primary_key=True),
  Column("date", DateTime),
)
class Test(object):
  pass
Test.mapper = mapper(Test, test)

try:
  test.drop()
except:
  pass
test.create()

date = mxDateTime.now()

t = Test()
t.id = '1'
t.date = date

objectstore.flush()
s = Test.mapper.get_by(id='1')
print mxDateTime.Age(mxDateTime.now(), s.date)




The last line of the output of this program is correct:
YYYY-MM-DD HH:MM:(+00)

(because the timedelta is zero).



Now in another file, do this (I've just removed the drop/create/ inserts):

import mx.DateTime as mxDateTime
from sqlalchemy import *

e = create_engine("postgres://database=test", echo=True)

test = Table("test", e,
  Column("id", String, primary_key=True),
  Column("date", DateTime),
)
class Test(object):
  pass
Test.mapper = mapper(Test, test)

s = Test.mapper.get_by(id='1')
print mxDateTime.Age(mxDateTime.now(), s.date)




This fails with:
Traceback (most recent call last):
  File "saDateTest2.py", line 15, in ?
    print mxDateTime.Age(mxDateTime.now(), s.date)
File "/usr/lib/python2.3/site-packages/mx/DateTime/DateTime.py", line 842, in RelativeDateTimeDiff
    diff = date1 - date2
TypeError: unsupported operand type(s) for -: 'DateTime' and 'datetime.datetime'



So the type of test.date is different between the two. I'd assume it should always be an mx.DateTime, so that I can use it in mx methods such as Age() without a lot of trouble.


I'm not sure if this is related:
http://article.gmane.org/gmane.comp.python.sqlalchemy.user/1672


--
Dimi Shahbaz, Software Engineer Specialist
California PASS Program
www.cyberhigh.fcoe.k12.ca.us






-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to