Skip to content

fix(postgres,cockroachdb): compare spatial columns against their default feature type and SRID - #12812

Open
samuelmbabhazi wants to merge 1 commit into
typeorm:masterfrom
samuelmbabhazi:fix/spatial-default-comparison
Open

fix(postgres,cockroachdb): compare spatial columns against their default feature type and SRID#12812
samuelmbabhazi wants to merge 1 commit into
typeorm:masterfrom
samuelmbabhazi:fix/spatial-default-comparison

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Contributor

Description of change

Fixes #12811

A geometry or geography column declared without spatialFeatureType or srid is created as plain geometry, which PostGIS and CockroachDB report back as feature type Geometry with SRID 0. findChangedColumns compared those values with the undefined metadata, so every such column produced the same no-op ALTER COLUMN ... TYPE on each migration:generate. The repository's own spatial Post test entity showed this drift: three phantom queries on both databases.

The comparison now applies the defaults the decorator reference already documents (feature type Geometry, SRID 0) on both sides, in the Postgres and CockroachDB drivers alike. Removing a feature type or SRID from an entity still converges: the stored value then differs from the default, one ALTER COLUMN ... TYPE geometry is generated, and the next run reports no changes.

Tests: a new schema-builder/idempotency/spatial-defaults case (postgres and cockroachdb) asserts no pending queries for such columns, and the idempotency assertions of the spatial suites, previously scoped to the dimensional table because of this drift, now cover the whole schema. Reverting the driver change makes exactly those three assertions fail with the three phantom queries. The idempotency and schema builder suites pass (155 tests), as do the spatial suites (27).

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links a relevant issue using a closing keyword:
    Fixes #NNNN, Closes #NNNN, or Resolves #NNNN
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md): no documentation change, the documented defaults are now honoured

…ult feature type and SRID

A geometry or geography column declared without spatialFeatureType or
srid is created as plain geometry, which the database reports back as
Geometry with SRID 0. The change detection compared those values with
the undefined metadata, so every such column produced the same no-op
ALTER COLUMN TYPE on each migration:generate.
@github-actions github-actions Bot added the linked-issue PR references an issue label Aug 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown

commit: a5b3c32

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linked-issue PR references an issue

Development

Successfully merging this pull request may close these issues.

Postgres/CockroachDB: spatial columns without spatialFeatureType or srid generate an endless no-op migration

1 participant