Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry array column causes error in PostgresQueryRunner when synchronizing #6019

Open
RobbieGM opened this issue May 5, 2020 · 2 comments

Comments

@RobbieGM
Copy link

RobbieGM commented May 5, 2020

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[x] 0.2.24 (latest) and 0.2.22 and 0.2.15

Steps to reproduce or a small repository showing the problem:

Create a model with a spatial column in a postgres database. For example:

import type { Point } from "geojson";

class Test {
  @Column('geometry', { spatialFeatureType: 'Point', srid: 4326, array: true })
  locations!: Point[];
}

The error happens when creating a connection and saving/synchronizing the new schema. The error given is:

TypeError: Cannot read property 'type' of undefined
    at PostgresQueryRunner.<anonymous> (C:\Users\Robbie\Code\project\node_modules\typeorm\driver\postgres\PostgresQueryRunner.js:2062:109)
    at step (C:\Users\Robbie\Code\project\node_modules\tslib\tslib.js:136:27)

The actual location of this error in the uncompiled TS code is here. This error has been reported before in #5747 but that issue blames the problem on changes in recent versions. I have this problem in a few different versions of typeorm, 0.2.24 (latest) and 0.2.22 and 0.2.15, so it doesn't seem to be something new.

@RobbieGM
Copy link
Author

RobbieGM commented May 7, 2020

Just made a bug repro for this and.. the bug isn't there! It it most likely an issue with my code somehow, although TypeORM is involved. I'll close this issue for now.

@RobbieGM RobbieGM closed this as completed May 7, 2020
@RobbieGM
Copy link
Author

RobbieGM commented May 8, 2020

I figured out what was happening. The problem happens when you try to make an array of geolocations, and I hadn't synchronized the database so the above code doesn't reproduce the error, but this repository should.
To reproduce:

  1. Clone repository
  2. Set your DATABASE_URL environment variable to a postgres database url.
  3. Run npm start once to set up the database tables.
  4. Run it again and it will throw an error when trying to diff the database.

@RobbieGM RobbieGM reopened this May 8, 2020
@RobbieGM RobbieGM changed the title Spatial columns cause error in PostgresQueryRunner on synchronize Geometry array column causes error in PostgresQueryRunner when synchronizing May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants