Sorry, in previous message I pressed Enter occasionally:
def testVeryOldDate(self):
class DateHolder(object):
def __init__(self, name, date):
self.name = name
self.date = date
metadata = MetaData()
dateTable = Table('DateHolder', metadata, Column('id',
Integer, primary_key=True),
Column('date', DateTime(timezone=true),
nullable = True) ,
Column('name', String()))
postgresSQLEngine =
sqlalchemy.create_engine("%(protocol)s://%(user)s:%(password)s@:%
(port)d/%(dbName)s"%\
{
'protocol':
Configuration.db.Protocol,
'user':
Configuration.db.User,
'password':
Configuration.db.Password,
'port':Configuration.db.Port,
'dbName':Configuration.db.DBName
}
)
mapper(DateHolder, dateTable )
metadata.drop_all(bind = postgresSQLEngine)
metadata.create_all(bind = postgresSQLEngine)
Session = sessionmaker(bind = postgresSQLEngine)
session = Session()
beforMatrixRevolution = datetime.date(year = 1919, month = 1,
day = 1)
afterMatrixRevolution = datetime.date(year = 1920, month = 1,
day = 1)
tmp = datetime.datetime.now().time()
beforMatrixRevolution =
datetime.datetime.combine(beforMatrixRevolution, tmp)
afterMatrixRevolution =
datetime.datetime.combine(afterMatrixRevolution, tmp)
session.add(DateHolder("First", afterMatrixRevolution))
session.commit()
session = Session()
amrHld = [dh for dh in session.query(DateHolder)]
amrHld = amrHld[0]
self.assertEqual(1920, amrHld.date.year)
session.add(DateHolder("First", beforMatrixRevolution))
session.commit()
session = Session()
cought = False
try:
dHld = [dh for dh in session.query(DateHolder)]
self.assertEqual(2, len(dHld))
years = [h.date.year for h in dHld]
years.sort()
self.assertEqual([1919, 1920], years)
except:
cought = True
self.assertTrue(cought)
session.commit()
metadata.drop_all(bind = postgresSQLEngine)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---