Bug
The array/range filter methods in the PostgREST query builder crash with TypeError when given a non-string iterable (e.g. an integer array), even though their signatures accept Iterable[Any]. Integer array columns (int[]) are common in Postgres, so .contains("ids", [1, 2, 3]) is a natural call.
in_ already handles this (it maps values through sanitize_param), but cs, cd, contains, contained_by, ov (and overlaps, which delegates to ov) do a bare ",".join(values) and fail.
Reproduce
from httpx import Client
from yarl import URL
from postgrest import SyncFilterRequestBuilder
from postgrest._sync.request_builder import RequestConfig
b = SyncFilterRequestBuilder(RequestConfig(Client(), URL('/t'), 'GET', {}, {}, None, {}))
b.contains('x', [1, 2, 3]) # TypeError: sequence item 0: expected str instance, int found
in_('x', [1, 2, 3]) works; cs/cd/contains/contained_by/ov/overlaps all raise.
Expected
The values should be coerced to str (as in_ effectively does), producing e.g. x=cs.{1,2,3}.
I have a fix + tests ready and will open a PR.
Bug
The array/range filter methods in the PostgREST query builder crash with
TypeErrorwhen given a non-string iterable (e.g. an integer array), even though their signatures acceptIterable[Any]. Integer array columns (int[]) are common in Postgres, so.contains("ids", [1, 2, 3])is a natural call.in_already handles this (it maps values throughsanitize_param), butcs,cd,contains,contained_by,ov(andoverlaps, which delegates toov) do a bare",".join(values)and fail.Reproduce
in_('x', [1, 2, 3])works;cs/cd/contains/contained_by/ov/overlapsall raise.Expected
The values should be coerced to
str(asin_effectively does), producing e.g.x=cs.{1,2,3}.I have a fix + tests ready and will open a PR.