Skip to content

Strings not being stringified when used with a JSONB column on PGSQL using jsonAttributes #1673

@dinodeSimon

Description

@dinodeSimon

Hi,

We are receiving a invalid input syntax for type json error when inserting a string value into a JSONB column on PGSQL using upsertGraph with a payload like:
{ jsonField: "value" }

Similar to this comment here it seems that if a plain string is used as a value for a JSONB column on PGSQL an error is generated even if the property is in jsonAttributes

#452 (comment)

It looks like jsonAttributes doesn't stringify the string because it isn't detected as an Object

if (isObject(value)) {

To work around this we can do something like this which works but it would be nice to know if there is a supported way or if we are missing something obvious

$beforeInsert() { if (this.jsonField) { this.jsonField = JSON.stringify(this.jsonField); } }

Thanks for building such an awesome orm. Let me know if you need more details or more detailed steps to repeat.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions