a fix for that is coming through at https://github.com/sqlalchemy/sqlalchemy/issues/7979
though it's best to give types to bindparam() objects if they don't have a value On Sun, May 1, 2022, at 11:53 AM, Mike Bayer wrote: > it looks like the bindparam() when not given a type is being coerced to > thinking it's an ARRAY, which might be a separate issue, but in any case, > give it a type so that there is no ambiguity (do you really need to use > bindparam() directly?) > > conn.execute( > table.select().where( > table.c.data.any(bindparam("data", type_=String)) > ), > {"data": "some text"}, > ) > > > On Fri, Apr 29, 2022, at 1:30 PM, Lele Gaifax wrote: >> Hi all, >> >> I'm hitting what is either a regression or a "deprecated" usage of PG >> ARRAY's any() method, trying to upgrade an app of mine from SA 1.4.35 to >> SA 1.4.36. >> >> The issue is within a quite complex query, with a filter expression like >> the following: >> >> query = query.filter(((CC.languages == None) | >> CC.languages.any(sa.bindparam('language')))) >> >> where CC.languages is a sqlalchemy.dialects.postgresql.ARRAY(UnicodeText()) >> column, >> and the language bindparam is the two-letter code of a language, say >> "it" or "en". >> >> That query works great since years in production using SA 1.3, and also >> in my work-in-progress dev branch using 1.4.x, producing something like >> >> ... >> AND (cc.languages IS NULL OR %(language)s = ANY (cc.languages)) >> ... >> >> Today I tried to upgrade the dev branch to SA 1.4.36 and several tests >> failed, because that filter is rendered as >> >> ... >> AND (cc.languages IS NULL OR %(language)s::TEXT[] = ANY (cc.languages)) >> ... >> >> In the note that follows >> https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.ARRAY.Comparator.any >> I read that the any() method "is superceded by" the any_() function, so >> maybe that's what I should do... but given that the above idiom has >> worked well for me for so long, this may very well be an unintended >> side effect of >> https://github.com/sqlalchemy/sqlalchemy/commit/63191fbef63ebfbf57e7b66bd6529305fc62c605. >> >> Thank you for any hint, >> ciao, lele. >> -- >> nickname: Lele Gaifax | Dire che Emacs è "conveniente" è come >> real: Emanuele Gaifas | etichettare l'ossigeno come "utile" >> l...@etour.tn.it | -- Rens Troost >> >> -- >> SQLAlchemy - >> The Python SQL Toolkit and Object Relational Mapper >> >> http://www.sqlalchemy.org/ >> >> To post example code, please provide an MCVE: Minimal, Complete, and >> Verifiable Example. See http://stackoverflow.com/help/mcve for a full >> description. >> --- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sqlalchemy+unsubscr...@googlegroups.com >> <mailto:sqlalchemy%2bunsubscr...@googlegroups.com>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sqlalchemy/87bkwjpzl0.fsf%40metapensiero.it. >> > > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/79239f5b-3c7b-45d0-b283-cf983d07b88f%40www.fastmail.com > > <https://groups.google.com/d/msgid/sqlalchemy/79239f5b-3c7b-45d0-b283-cf983d07b88f%40www.fastmail.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/bea44fa5-e2b7-4a56-b82c-5f913502d4a0%40www.fastmail.com.