Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB Adapter with TIME field. ValueError: invalid literal for int() with base 10 #170

Closed
jrborbars opened this issue May 2, 2015 · 0 comments

Comments

@jrborbars
Copy link

Hi,

I'm new to mongoDB and still having some problems with a TIME field. When I set a TIME field in the table, fill the input field of a sqlform (only time is allowed) and send the data to table, all the record is inserted without any warning. But when I try to show in the sqlform, I receive a message:


  Traceback (most recent call last):
  File "/home/xxx.../applications/ras/controllers/appadmin.py", line 269, in select
    *fields, limitby=(start, stop))
  File "/home/xxx.../gluon/packages/dal/pydal/objects.py", line 2026, in select
    return adapter.select(self.query,fields,attributes)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/mongo.py", line 353, in select
    result = processor(rows, fields, newnames, False)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1596, in parse
    value = self.parse_value(value,ft,blob_decode)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1450, in parse_value
    return self.parsemap[key](value,field_type)
  File "/home/xxx.../gluon/packages/dal/pydal/adapters/base.py", line 1472, in parse_time
    time_items = map(int,str(value)[:8].strip().split(':')[:3])
ValueError: invalid literal for int() with base 10: '2000-01-'

Web2py 2.10.4.

Trying to understand what happened, I'm googled for some info, and found the Mongo adapter code (yes, I didn't tried in my own computer).

Reading the code (in pydal/adapters/mongo.py), I see a (possible) clue: The lines 148 to 163 is, in some way, weird for my reading. Maybe I misunderstood some point, but this


t = datetime.time(0,0,0)

is a formatter for a field type DATE, and this


t = datetime.date(2000,1,1)

is a formatter for a field type TIME ?

My second bet is that the parser of time (the time_itens above) need to be modified to work with time in mongo.

Best regards, and keep going the invaluable work with this lib.

mdipierro added a commit that referenced this issue May 3, 2015
fix #170 (parse parse_time for mongo adapter), added tests
stephenrauch added a commit to stephenrauch/pydal that referenced this issue May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant