Deleting a record in GAE (gql.py) fails

Bug #522416 reported by Paulus Zegwaard
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
web2py-wiki
New
Undecided
Unassigned

Bug Description

In GAE (inside the SDK) calling this:
db(db[data_table].id == id).delete()

results in a tracback, ultimately with an issue here:
gluon/contrib/gql.py", line 681, in delete
    counter = items.count()
TypeError: count() takes exactly one argument (0 given)

Seems that items is a list, and the count method of a list takes a value to count inside the list, i.e. it's not counting the items in the list.

Just wondering whether the following code was intended (at least it doesn't fail :-) ), file gluon/contrib/gql.py:

    def count(self):
        (items, tablename, fields) = self._select()
        self._db['_lastsql'] = 'COUNT WHERE %s' % self.where
        return len(items) # original = >return items.count()

    def delete(self):
        self._db['_lastsql'] = 'DELETE WHERE %s' % self.where
        (items, tablename, fields) = self._select()
        tableobj = self._db[tablename]._tableobj
        counter = self.count() # original => items.count()
        gae.delete(items)
        return counter - self.count() # original => items.count()

But I haven't studied the code in depth, so hopefully the gql.py maintaner can confirm whether these are just some typos as I expect or that there is a deeper issue.

Paulus

Tags: gae gql.py
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.