alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

datetime problem in GAE #103

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From mulone.m...@gmail.com on September 01, 2010 13:07:38

This raise an exception in GAE, in sqlite all working fine. This is web2py from trunk.


models/db.py


import datetime db.define_table('posts',
db.Field('id', 'id'),
db.Field('title', 'string', length=255, default=""),
db.Field('created_on', 'datetime'), migrate=True)

posts = db(db.posts.id>0).select() if not posts: id1 = db.posts.insert(title="This is my 1 title",created_on=datetime.date(2010, 9, 1)) id2 = db.posts.insert(title="This is my 2 title",created_on=datetime.date(2010, 8, 31)) id3 = db.posts.insert(title="This is my 3 title",created_on=datetime.date(2010, 8, 30)) id4 = db.posts.insert(title="This is my 4 title",created_on=datetime.date(2010, 7, 20)) id5 = db.posts.insert(title="This is my 5 title",created_on=datetime.date(2010, 5, 15))


controllers/default.py


def index(): import datetime

date1 = datetime.date(2010,1,1)
date2 = datetime.date(2010,9,10)
query = (db.posts.created_on>=date1)
posts = db(query).select() 
if posts: 
    post = posts[0] 
    id = post.id 
    title = post.title
    created = post.created_on         

return dict(id=id,title=title,created=created)

Attachment: web2py.app.datesgae.w2p

Original issue: http://code.google.com/p/web2py/issues/detail?id=104

alfonsodg commented 10 years ago

From massimod...@gmail.com on September 01, 2010 11:12:47

I think the problem is trying to insert a date in datetime. Please try replace datetime.date with datetime.datetime

do you think this should be supported?

alfonsodg commented 10 years ago

From mulone.m...@gmail.com on September 01, 2010 12:47:17

yes you are right this is the problem. Mmmh I think this is not a must, perhaps better raise exception.

alfonsodg commented 10 years ago

From massimod...@gmail.com on September 12, 2010 20:14:36

I changed it and you should no longer get any error. Please check it.

Status: Fixed