Skip to content

TypeORM + Postgres: HStore implementation broken & subject to "hstore injection" #4719

@tobyhinloopen

Description

@tobyhinloopen

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 (0.2.18)
[ ] @next
[x] 0.2.18 (or put your version here)

Steps to reproduce or a small repository showing the problem:

For an Entity column like this:

class Thing {
  // ...
  @Column({ type: "hstore", hstoreType: "object" })
  public values: Record<string, string>;
}

The values property is not restored properly when saving & restoring the
entity: Empty string values in the map (EG { foo: "1", bar: ""} cause the object to break.

For clarity & reproduction, I've created an isolated bare-minimum repository that acts as an example of the issue.

See https://github.com/tobyhinloopen/typeorm-failure for a runnable example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions