to_list does not have a special case for `bytes`

Issue #3660 resolved
Antti Haapala created an issue

I'm using bytea (16 byte md5 digest) in PostgreSQL as a primary key. Unfortunately to_list which is used for example by _get_impl does not have a special case for bytes and thus get() complains about "Incorrect number of values in identifier to formulate primary key for query.get(); primary key columns are 'file.id'"

Comments (4)

  1. Mike Bayer repo owner

    Hello -

    Please include test cases!!! I have no idea what _get_impl() is from reading this and it's not good form to make me grep through my own code to know what you're talking about.

    For guidelines on test cases please see http://stackoverflow.com/help/mcve

  2. Mike Bayer repo owner
    • Fixed bug in "to_list" conversion where a single bytes object would be turned into a list of individual characters. This would impact among other things using the :meth:.Query.get method on a primary key that's a bytes object. fixes #3660

    → <<cset 01809bddff5b>>

  3. Antti Haapala reporter

    Haha, sorry about not including the test case nor linking to source code; I was in a hurry and decided perhaps wrongly that I'd better write this down without a test case and amend later than to forget to report this altogether.

    As for someone who comes across this again, for me the workaround was as easy as wrapping the bytes pk in a list: .get([b'123']).

  4. Log in to comment