Seems DAL alway looks the first "column" if all tables is ID field   (after 
remove _id column from mongo)
{ "_id" : ObjectId("4de83c816afb62e8367163b1"), "first_name" : "koko", 
"last_name":"yo", "password"........ } *
*

On Wednesday, May 9, 2012 7:42:56 PM UTC+9, Francisco Costa wrote:
>
> I've enumerated fields and colnames and they are like this:
>
> fields:
> id
> text
> integer
> string
>
>
> colnames:
> city
> age
> _id
> name
>
>
>  I believe they don't match and thats why there's this error:
>
> File "/opt/web2py/gluon/dal.py", line 8134, in select
> return adapter.select(self.query,fields,attributes)
> File "/opt/web2py/gluon/dal.py", line 4711, in select
> return processor(rows,fields,colnames,False)
> File "/opt/web2py/gluon/dal.py", line 1681, in parse
> self.parse_value(value, fields[j].type,blob_decode)
> File "/opt/web2py/gluon/dal.py", line 1575, in parse_value
> return self.parsemap[key](value,field
>
> _type)
>   File "/opt/web2py/gluon/dal.py", line 1641, in parse_id
>
>     return int(value)
> ValueError: invalid literal for int() with base 10: 'Toronto'
>
>
>
>
>
> On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:
>>
>> Please try again.
>>
>> On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:
>>>
>>> missing a colon at the end of the line 4677
>>>
>>> if key == 'id'
>>>
>>>
>>> and now I get this error
>>>
>>>   File "/opt/web2py/gluon/dal.py", line 8134, in select
>>>     return adapter.select(self.query,fields,attributes)
>>>   File "/opt/web2py/gluon/dal.py", line 4711, in select
>>>     return processor(rows,columns,False)
>>>   File "/opt/web2py/gluon/dal.py", line 1675, in parse
>>>     for j,colname in enumerate(colnames):
>>> TypeError: 'bool' object is not iterable
>>>
>>>
>>> maybe because of the False on line 4711
>>>
>>>
>>>
>>>
>>> On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:
>>>>
>>>> Thanks for your help and check on this. I just committed a fix in trunk 
>>>> that should address it. Please let me know.
>>>>
>>>> On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:
>>>>>
>>>>> I think that the mongofields_dict.keys() don't match to the data in 
>>>>> the rows
>>>>>
>>>>> mongofields_dict:
>>>>> id
>>>>> name
>>>>> age
>>>>> city
>>>>> rows:
>>>>> Toronto
>>>>> 66L
>>>>> 24652490551171733682233802752L
>>>>> John
>>>>>
>>>>>
>>>>> On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:
>>>>>>
>>>>>> Your linennumbers do not much the code in trunk. Please try the code 
>>>>>> in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
>>>>>> colnames, blob_decode=True) function. I suspect mongo does not return 
>>>>>> the 
>>>>>> columns in the order web2py think it does. Can you print the input of 
>>>>>> the 
>>>>>> parse function?
>>>>>>
>>>>>> On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:
>>>>>>>
>>>>>>> So I have this:
>>>>>>>
>>>>>>> import sys
>>>>>>> import time
>>>>>>> from gluon.dal import DAL, Field
>>>>>>> mongo = DAL('mongodb://localhost:27017/tymr')
>>>>>>> mongo.define_table('user',
>>>>>>>              Field('name', 'text'),
>>>>>>>              Field('age',  'integer'),
>>>>>>>              Field('city', 'string')
>>>>>>>              )
>>>>>>>
>>>>>>> def insert_users():
>>>>>>>     mongo.user.insert(name='John', age=66, city='Toronto')
>>>>>>>     mongo.user.insert(name='Mark', age=43, city='Boston')
>>>>>>>     mongo.user.insert(name='Tom',  age=43, city='Detroit')
>>>>>>>     mongo.user.insert(name='Jim',  age=18, city='Detroit')
>>>>>>>     mongo.user.insert(name='Jack', age=18)
>>>>>>>     mongo.user.insert(name='Eric', city='Boston')
>>>>>>>     return 'users in database'
>>>>>>>
>>>>>>> def find_users():
>>>>>>>     users = mongo(mongo.user.age==66).select()
>>>>>>>     return dict(users=users)
>>>>>>>
>>>>>>>
>>>>>>> after I run *insert_users* I check in MongoDb via terminal and 
>>>>>>> everything is correct:
>>>>>>> > db.user.find()
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000000"), "city" : "Toronto", 
>>>>>>> "age" : NumberLong(66), "name" : "John" }
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000001"), "city" : "Boston", 
>>>>>>> "age" : NumberLong(43), "name" : "Mark" }
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000002"), "city" : "Detroit", 
>>>>>>> "age" : NumberLong(43), "name" : "Tom" }
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000003"), "city" : "Detroit", 
>>>>>>> "age" : NumberLong(18), "name" : "Jim" }
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000004"), "age" : 
>>>>>>> NumberLong(18), "name" : "Jack" }
>>>>>>> { "_id" : ObjectId("4fa80feea34feb34f8000005"), "city" : "Boston", 
>>>>>>> "name" : "Eric" }
>>>>>>>
>>>>>>> but when I run *find_users* I get this error:
>>>>>>>
>>>>>>>   File "/opt/web2py/gluon/dal.py", line 7578, in select
>>>>>>>     return adapter.select(self.query,fields,attributes)
>>>>>>>   File "/opt/web2py/gluon/dal.py", line 4290, in select
>>>>>>>     return self.parse(rows,fields,mongofields_dict.keys(),False)
>>>>>>>   File "/opt/web2py/gluon/dal.py", line 1600, in parse
>>>>>>>     self.parse_value(value, fields[j].type,blob_decode)
>>>>>>>   File "/opt/web2py/gluon/dal.py", line 1496, in parse_value
>>>>>>>     return self.parsemap[key](value,field_type)
>>>>>>>   File "/opt/web2py/gluon/dal.py", line 1562, in parse_id
>>>>>>>     return int(value)
>>>>>>> ValueError: invalid literal for int() with base 10: 'Toronto'
>>>>>>>
>>>>>>>
>>>>>>>

Reply via email to