Opened 9 years ago

Closed 9 years ago

#2483 closed defect (invalid)

sqlite3 not processing paramaters?

Reported by: Bryan Newbold <bnewbold@…> Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: major Keywords: sqlite
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


When overriding the generic update_object method like so:

def update_item(request, model, object_id=None, slug=None,
        slug_field=None, template_name=None, template_loader=loader,
        extra_context=None, post_save_redirect=None,
        login_required=False, follow=None, context_processors=None,
    if request.POST:
        i = Item.objects.get(pk=object_id)
        new_data = request.POST.copy()
        new_data['type'] = str(i.type_id)
        new_data['name'] =
        new_data['added_date_time'] = time.strftime('%H:%M')
        new_data['added_date_date'] = time.strftime('%Y-%m-%d')
        request.POST = new_data

    return update_object(request, model, object_id, slug,
            slug_field, template_name, template_loader,
            extra_context, post_save_redirect,
            login_required, follow, context_processors,

I get an OperationalError with sqlite... the problem is the database query:

query = 'UPDATE "items_item" SET "name"=?,"type_id"=?,"status_id"=?,"added_date"=?,"giver"=?,"taker"=?,"checkedout_date"=?,"id_left_id"=?,"description"=?,"image"=? WHERE "id"=?'

looking up a step in the stack, there's:

params=('Adaptation', '1', '1', '2006-08-04 17:23:00', None, 'asdf', None, '1', None, None, 1)


'UPDATE "items_item" SET "name"=%s,"type_id"=%s,"status_id"=%s,"added_date"=%s,"giver"=%s,"taker"=%s,"checkedout_date"=%s,"id_left_id"=%s,"description"=%s,"image"=%s WHERE "id"=%s'

The current converty_query method in sqlite3 is:

def convert_query(self, query, num_params):
        return query % tuple("?" * num_params)

Which doesn't make any sense to me... shouldn't it be populating the query with the parameters? Am I just lost? Should the query be handled earlier on?

Change History (2)

comment:1 Changed 9 years ago by Bryan Newbold <bnewbold@…>

Forgot to mention, everything works fine in the admin interface, etc... this looks to me like it was just never fully implemented.

comment:2 Changed 9 years ago by Bryan Newbold <bnewbold@…>

  • Resolution set to invalid
  • Status changed from new to closed

Alright i'm a moron, I just wasn't populating all the required fields correctly. I'd argue that the error should have been more descriptive, as this was an easy mistake for a novice to make.

Note: See TracTickets for help on using tickets.
Back to Top