Skip to content

Refuse arrays of calls that return a BLOB-stored type - #181

Merged
LucaCappelletti94 merged 2 commits into
mainfrom
upstream/blob-returning-functions
Oct 29, 2026
Merged

LucaCappelletti94 merged 2 commits into
mainfrom
upstream/blob-returning-functions

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Collaborator

#173 refused an array element stored as a BLOB only when the element was a column or a cast, because a function call had no type pg2sqlite could read. So ARRAY[decode(x, 'hex')], array_agg(gen_random_uuid()) under UuidRepresentation::Blob, array_agg(coalesce(b, NULL)) over a bytea column, ARRAY[f()] for a schema function returning bytea, and ARRAY[ST_Point(1, 2)] with SQLiteGIS still translated and then failed in SQLite with JSON cannot hold BLOB values.

An element's PostgreSQL type is now worked out from what the statement writes: a column's declaration, a cast, a literal (an untyped one as unknown, as PostgreSQL types it), or a call's result. A call is resolved through sql-traits' call_result_type_name (connetto-rs/sql-traits#179 and #180), which searches pg_catalog first, picks the overload by argument types and follows polymorphic results, so coalesce, nullif, min and array_agg over bytea answer bytea. A call sql-traits does not know and that passes through to SQLiteGIS takes its result type from the SQLiteGIS catalog, which now records one per entry, checked against the storage class the sqlitegis crate declares.

An element produced by an operator or a CASE is still not typed, so ARRAY[b || b] still fails in SQLite.

@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit a04863f into main Oct 29, 2026
19 checks passed
@LucaCappelletti94
LucaCappelletti94 deleted the upstream/blob-returning-functions branch October 31, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant