fix(database-pgsql): normalise jsonb → json in introspector type map#69
Open
michalbiarda wants to merge 1 commit into
Open
fix(database-pgsql): normalise jsonb → json in introspector type map#69michalbiarda wants to merge 1 commit into
michalbiarda wants to merge 1 commit into
Conversation
PgSqlGenerator maps entity type 'json' to JSONB in DDL, which is correct (JSONB is preferred in PostgreSQL for indexing and performance). However, the introspector returned 'jsonb' for those columns, while the entity schema still held 'json'. With no alias in Column::typeEquals(), the diff calculator reported a spurious Modify on every json column after the initial migration. Mapping 'jsonb' → 'json' in PgSqlIntrospector::TYPE_MAP normalises the round-trip so introspected JSONB columns compare equal to entity-declared json columns. The fix is intentionally scoped to the PgSQL driver — MySQL is unaffected (it stores and introspects JSON under the same name). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
PgSqlGeneratormaps entity typejson→JSONBin DDL (correct — JSONB is preferred in PostgreSQL)PgSqlIntrospectorread the column back asjsonb, while the entity schema heldjsonColumn::typeEquals()for this pair, so the diff calculator reported a spuriousModifyon everyjsoncolumn indefinitely'jsonb' => 'json'inPgSqlIntrospector::TYPE_MAP, normalising the round-trip at the driver levelCloses #68
Steps to reproduce (before fix)
#[Column(type: 'json')]db:migrate— column is created asJSONBin PostgreSQLdb:diff— reportsModify columndespite no changesExpected behavior
db:diffreports no changes after the column has been created.Test plan
it normalises jsonb to json so introspected columns match entity-declared typeit produces no diff when entity declares json and database stores jsonb🤖 Generated with Claude Code