Skip to content

Can persist JSON cannot Parse JSON #96

@rightisleft

Description

@rightisleft

I have an VO[] that gets persisted to postgres.

@Column(ColumnTypes.JSON, {nullable: true})
weights: VO[];

The field value in the database is:
[{"documentId":140,"topicId":24,"weight":0.25},{"documentId":140,"topicId":24,"weight":0.25},{"documentId":140,"topicId":26,"weight":0.25},{"documentId":140,"topicId":27,"weight":0.25}]

When i try and read that out of the database, it calls:
PostgresDriver.ts => prepareHydratedValue

and calls JSON.parse(value)

This results in:
Unexpected token o in JSON at position 1
Why is the field value in the database not stringified?

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