Skip to content

PostgreSQL driver doesnt read Z and M Geometry suffixes from coord_dimension #12747

Closed

Description

@SmallhillCZ

Issue description

When loading tables form DB and using PostGIS, PostgreSQL driver doesnt take into account coord_dimension column of geometry_columns table. Therefore when using specific geometry spatialFeatureType like GeometryZ TypeORM generates migration to this type over and over again.

Expected Behavior

Translate coord_dimension and type columns of geometry columns table into correct spatialFeatureType
ie

coord_dimension type spatialFeatureType
2 GEOMETRY Geometry
3 GEOMETRY GeometryZ
3 GEOMETRYM GeometryM
4 GEOMETRY GeometryZM

Actual Behavior

Only type field is taken into account, so if I create a table with GeometryZ column, generate migration and apply it, all following generated migrations will still have this change included, despite columns being already GeometryZ:

public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`ALTER TABLE "test" ALTER COLUMN "geometry" TYPE geometry(geometryz,5514)`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`ALTER TABLE "test" ALTER COLUMN "geometry" TYPE geometry(GEOMETRY,5514)`);
}

Steps to reproduce

  • create entity with GeometryZ column
    @Column({ type: "geometry", spatialFeatureType: "geometryz", srid: 5514 })
  • generate migration
  • run migrations
  • generate migration again
  • see typeorm trying to ALTER COLUMN geometry again to GeometryZ, despite it being already GeometryZ

My Environment

Dependency Version
Operating System Debian GNU/Linux 12 (bookworm)
Node.js version v22.16.0
Typescript version 5.8.3
TypeORM version 1.1.0

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • capacitor
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Activity

  1. changed the title [-]PostgreSQL driver doesnt read coord_dimension[/-] [+]PostgreSQL driver doesnt read Z and M suffixes from coord_dimension[/+] on Jul 31, 2026
  2. changed the title [-]PostgreSQL driver doesnt read Z and M suffixes from coord_dimension[/-] [+]PostgreSQL driver doesnt read Z and M Geometry suffixes from coord_dimension[/+] on Jul 31, 2026
  3. added a commit that references this issue on Aug 2, 2026
    30b4525
  4. added a commit that references this issue on Aug 26, 2026
    d1e3d9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions