Skip to content

Cannot read then save the same entity with point #4004

Closed

Description

@onionhammer

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:

[ ] latest
[ ] @next
[x] 0.2.14

When position goes into the database as '(-23, -23)', and comes back as { x: -23, y: -23 }, so when it re-inserts it fails with

QueryFailedError: invalid input syntax for type point: "{"x":-23,"y":-23}"

it("Can insert and re-insert a position", async () => {
  const connection = await connectFromEnv();

  await connection.transaction(async db => {

    const locations = db.getRepository(Location);

    // Save a location
    let id;
    {
      const location = await locations.save({
        line1: "Test",
        position: "(-23,-23)"
      } as Location);

      id = location.id;
    }

    // Update location -- Fails
    {
      const location = await locations.findOneOrFail(id);
      console.log(location);
      await locations.save(location);
    }

  });
});

Activity

  1. vlapo commented on Apr 21, 2019

    @vlapo
    Contributor

    Could you please provide your Location entity definition?

  2. onionhammer commented on Apr 24, 2019

    @onionhammer
    Author

    @vlapo sorry for the late reply;

    Location looks like this

    @Entity("locations")
    export class Location {
    
      
      @PrimaryGeneratedColumn("uuid")
      id: string
    
      /** Latitude/Longitude */
      @Column({ type: "point", nullable: true })
      position: string
    
    }
  3. vlapo commented on Apr 24, 2019

    @vlapo
    Contributor

    Postgres do not support Point type. You have to use:

    @Column({ 
        type: 'geography',
        nullable: true,
        spatialFeatureType: 'Point',
        srid: 4326
    })
  4. onionhammer commented on Apr 25, 2019

    @onionhammer
    Author

    @vlapo With the definition I have above, it creates the table with column type of 'point'

    image

  5. vlapo commented on Apr 25, 2019

    @vlapo
    Contributor

    Ou, sorry. I understand now. You are not using PostGIS. It looks like a bug with converting data.

  6. github-actions commented on Sep 18, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

  7. onionhammer commented on Sep 18, 2025

    @onionhammer
    Author

    Was this resolved?

  8. reopened this on Sep 18, 2025
  9. gioboa commented on Sep 18, 2025

    @gioboa
    Collaborator

    Was this resolved?

    Can you test with the latest version?

  10. Cprakhar commented on Dec 18, 2025

    @Cprakhar
    Collaborator

    This issue resulted from the standard geometric types not being properly normalized for point/circle in the PostgresDriver.ts -> preparePersistentValue().

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions