Skip to content

fix(database-pgsql): normalise jsonb → json in introspector type map#69

Open
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/pgsql-json-type-normalisation
Open

fix(database-pgsql): normalise jsonb → json in introspector type map#69
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/pgsql-json-type-normalisation

Conversation

@michalbiarda
Copy link
Copy Markdown

Summary

  • PgSqlGenerator maps entity type jsonJSONB in DDL (correct — JSONB is preferred in PostgreSQL)
  • PgSqlIntrospector read the column back as jsonb, while the entity schema held json
  • No alias existed in Column::typeEquals() for this pair, so the diff calculator reported a spurious Modify on every json column indefinitely
  • Fixed by mapping 'jsonb' => 'json' in PgSqlIntrospector::TYPE_MAP, normalising the round-trip at the driver level

Closes #68

Steps to reproduce (before fix)

  1. Define an entity with #[Column(type: 'json')]
  2. Run db:migrate — column is created as JSONB in PostgreSQL
  3. Run db:diff — reports Modify column despite no changes

Expected behavior

db:diff reports no changes after the column has been created.

Test plan

  • it normalises jsonb to json so introspected columns match entity-declared type
  • it produces no diff when entity declares json and database stores jsonb

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the bug Something isn't working label May 13, 2026
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.

Spurious Modify diff on json columns due to json/jsonb type mismatch

1 participant