You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been experimenting with JSON/B support and have noticed the following:
With
@Column("json", { nullable: true })
myJsonField: any
The following persists:
myJsonField = {features: ["a", "b", "c"]}
but this doesn't:
myJsonField = ["a", "b", "c"]
persist throws
error: invalid input syntax for type json
[1] at Connection.parseE (/Users/Danijel/projects/am/am-api/node_modules/pg/lib/connection.js:554:11)
[1] at Connection.parseMessage (/Users/Danijel/projects/am/am-api/node_modules/pg/lib/connection.js:381:17)
[1] at Socket.<anonymous> (/Users/Danijel/projects/am/am-api/node_modules/pg/lib/connection.js:117:22)
[1] at emitOne (events.js:96:13)
[1] at Socket.emit (events.js:188:7)
[1] at readableAddChunk (_stream_readable.js:176:18)
[1] at Socket.Readable.push (_stream_readable.js:134:10)
[1] at TCP.onread (net.js:551:20)
According to the JSON spec, both examples are valid JSON. Should this work?
In this use case, storing features as a seperate table is overkill. Also using an @EmbeddedTable would also be overkill as I'm not storing properties in the embedded table, just a simple array.
Activity
[-]Postgres JSON/B and arrays Question[/-][+][Postgres] JSON/B and arrays Question[/+]dcworldwide commentedon Jan 10, 2017
Note: There is a workaround, use @column("simple_array"). This solves my requirement, so will close.
pleerock commentedon Jan 10, 2017
Can you take a look if underlaying
pgdriver and postgres itself support storing array-json?xfoxfu commentedon Jul 3, 2017
postgres support storing array-json.