I am trying to query a data set to return all list:string items not null.
My example table:
db.define_table('newItems',
Field('name', 'string'),
Field('tasks', 'list:string'))
A query for None like so:
for item in db(db.newItems.tasks != None).select(db.newItems.tasks):
Returns:
[]
[]
[u'Wash Dog', u'Mow Yard']
[]
[u'Do X', u'Then do Y']
[]
How do I structure the query so that it only returns:
[u'Wash Dog', u'Mow Yard']
[u'Do X', u'Then do Y']
Thank you
update:
The answer works when tested on sqlite but it does not work with mongodb. The empty list [] is passed as '' that yields the wrong result:
In [4]: db.Tasks.email != []
Out[4]: <Query {'email': {'$ne': ''}}>
mongo shell:
> db.Tasks.find().count()
1195 (total records)
> db.Tasks.find({'email': {'$ne': ''}}).count()
1195
The correct query should be:
> db.Tasks.find({email: {$ne: [ ] }}).count()
108
Is this is a bug in mongo dal or is there another way I can specify the empty list?