Opened 18 years ago

Closed 18 years ago

#2483 closed defect (invalid)

sqlite3 not processing paramaters?

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

Description

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,
        template_object_name='object'):
    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'] = i.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,
            template_object_name)

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)

and

'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 by Bryan Newbold <bnewbold@…>, 18 years ago

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

comment:2 by Bryan Newbold <bnewbold@…>, 18 years ago

Resolution: invalid
Status: newclosed

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