Inserting multiple values doesn't work in some cases

Issue #1057 resolved
Former user created an issue

inserting multiple rows using single list of row values doesn't work, ex.

conn.execute("insert into users (user_id, user_name) values (?, ?)", [(10,"donkey")]((9,"barney"),))

or

 conn.execute("insert into users (user_id, user_name) values (%s, %s)", [[4,"ed"]([4,"ed"), [5,"horse"](5,"horse")])

Attached patch fixes this.

Comments (4)

  1. Mike Bayer repo owner

    why not follow what the method docstring says (or intends to say, in which case its just a doc fix) ?

     in the case of 'raw' execution which accepts positional parameters,
            it [being *multiparams](it) may be a list of tuples or lists.
    

    __distill_params() is already quite a beast, and we'd be better off not being so agnostic in the params we accept. Also it's unclear if this would work with the PG ARRAY type. I'm even +1 on reducing the *multiparams to only accept a list of tuples or dicts.

  2. Mike Bayer repo owner

    sorry, the attached patch also creates a ton of errors in the unit tests due to the extra ambiguity presented in the API, so TMTOWTDI + it actually breaks things pretty much kills this one for me.

  3. Former user Account Deleted

    It would be nice then to mention somewhere in the docs that execute accepts list of dicts but not list of tuples or lists. Thanks for looking into this anyway.

  4. Log in to comment