fix(codegen): map postgres range columns to PgRange for oxide format - #25
Draft
Mattt (aevv) wants to merge 1 commit into
Draft
Conversation
sea-schema surfaces range columns as ColumnType::Custom, which write_rs_type renders as String. That is correct for the standard format, where get_col_type_attrs pairs it with select_as = "text", but the oxide format decodes rows straight into the model struct with sqlx::FromRow, so a numrange column produced a struct that compiled and then failed at runtime with "Rust type Option<String> is not compatible with SQL type NUMRANGE". Render the six range types as sqlx's PgRange instead, following the element types sqlx implements and honouring --date-time-crate for the temporal ones. Two constraints shape the output. PgRange implements neither Serialize nor Deserialize, so range fields carry #[serde(skip)]; skipping a field requires Default to deserialize, so they are always Option regardless of nullability. BigDecimal implements only PartialEq, so an entity holding a numrange cannot derive Eq, which get_oxide_eq_needed now accounts for the way get_eq_needed already does for floats. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mattt (aevv)
changed the base branch from
oxide-codegen
to
mattt/emit-uuid-import-in-oxide-codegen
August 23, 2026 11:07
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.
Stacked on #24 — review that one first; this PR's diff is the second commit only, and its base retargets to
oxide-codegenonce #24 merges.Range columns generate a struct that compiles and then fails to decode. sea-schema surfaces them as
ColumnType::Custom, whichwrite_rs_typerenders asString— correct for the standard format, whereget_col_type_attrspairs it withselect_as = "text", but the oxide format decodes straight into the model struct viasqlx::FromRow:This is latent rather than live:
bin_table_data.bin_rangehas been anint8rangegenerating asOption<String>for a while, butoxidenever hits it becauseev_dbhand-writes its ownBinTableDatawithOption<PgRange<i64>>— plausibly because the generated one was unusable. This PR makes the generated type match that hand-written one, so the workaround can eventually go away.All six range types now render as sqlx's
PgRange, honouring--date-time-cratefor the temporal ones.Two constraints shape the output:
PgRangeimplements neitherSerializenorDeserialize, andserdehas no impls forstd::ops::Bound, so there is nothing to derive. Range fields carry#[serde(skip)]; skipping needsDefaultto deserialize, so they are alwaysOptionregardless of nullability. This matches existing practice — the hand-writtenBinTableDataderives no serde at all — but it does mean a range is silently absent from JSON rather than failing loudly. If a consumer ever needs it serialized, the fix is to emit a representation here rather than to un-skip.BigDecimalimplements onlyPartialEq, so an entity holding anumrangecannot deriveEq.get_oxide_eq_neededhandles that the wayget_eq_neededalready does for floats. Ranges overEqelement types keep the derive.Verified by regenerating
evervault/common-specsagainst a live Postgres and reading a realnumrangerow back into the generated struct.The three pre-existing
sea-orm-codegen --libfailures (test_get_info,test_get_rs_type_with_chrono,test_gen_postgres) are theJsonmapping ones already noted in #24, unrelated to this change.🤖 Generated with Claude Code