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"
le...@etour.tn.it | -- Rens Troost