Add opt-in #[sea_orm(try_getable_array)] to DeriveValueType for Vec<T> query results#3108
Merged
Conversation
1 task
…> query results Closes #2967. Supersedes #2972. DeriveValueType wrappers can opt in to a generated TryGetableArray impl so Vec<Wrapper> is readable from a SQL array column in FromQueryResult structs. Opt-in and non-disruptive: default behaviour unchanged; the impl delegates to the inner type's Vec support under the postgres-array feature. Includes a Postgres round-trip test reading an int[] column into Vec<GoodId>.
0d91654 to
869c8f0
Compare
pull Bot
pushed a commit
to langyo/sea-orm
that referenced
this pull request
Jul 3, 2026
…rm-sync The mock.rs test module imported `futures_util::TryStreamExt` unconditionally, but the sync variant has no futures_util dependency (it uses `StreamShim::try_next` instead, already gated on `feature = "sync"`). A full make-sync regen therefore didn't compile its lib unit tests. Gate the import on `not(feature = "sync")` to match the StreamShim pattern. Also regenerate sea-orm-sync to catch up with recently-merged changes (SeaQL#2940 docs, SeaQL#3106 sync warning, SeaQL#3108 try_getable_array, non_exhaustive).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2967. Supersedes #2972.
Problem
DeriveValueTypewrappers (e.g.struct GoodId(i32)) don't implementTryGetableArray, so they can't be used asVec<GoodId>inFromQueryResultstructs (Postgres arrays):Approach — opt-in, non-disruptive
Per the discussion on #2972, this is opt-in rather than automatic, so default behaviour is unchanged and there's no risk to existing wrappers (including nested
Vec<Vec<T>>cases):#[sea_orm(try_getable_array)]flag generatesimpl TryGetableArray for GoodId, delegating to the inner type'sVecsupport — so it only compiles whenVec<inner>: TryGetable. Named to match the existingtry_from_u64opt-in flag (both name the trait they generate), and to avoid confusion witharray_type.postgres-arrayfeature (like the existingNotU8impl).postgres-array+with-json(no trait-coherence conflict with the JSONTryGetableArrayblanket).Test
Postgres round-trip in
value_type_tests: readsSELECT ARRAY[1,2,3]::int4[]intoVec<GoodId>viaFromQueryResult.Note:
sea-orm-syncregenerates from this at release time.