Pg: Inserting text[] array

Created on 8 Nov 2018  Â·  7Comments  Â·  Source: go-pg/pg

Hello !
When I try to insert an object with an array, I see that the query sent to Postgre is not valid.

INSERT INTO ... '["tag1", "tag2"]' is generated instead of INSERT INTO ... '{"tag1", "tag2"}'

Do you have any idea what went wrong ?

Thank's :)

Most helpful comment

You should fix tags in you example json:"tags,omitempty" sql:",array".

All 7 comments

That looks like JSON, you probably need to add ,array tag to the struct field.

I've added sql:",array" to the field of my struct, but the error is still there.

Okay, now it is time to create a small program that reproduces the problem.

Same here trying to find the reason, seems it ignores sql:",array" somehow

Can you please re-open the issue @vmihailenco ?
Here's a small program that reproduces the problem.
https://github.com/gmolveau/go-pg-bug

You should fix tags in you example json:"tags,omitempty" sql:",array".

Oh... well... that was it ¯_(ツ)_/¯ Thank's for your help !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

l0gicgate picture l0gicgate  Â·  5Comments

kieusonlam picture kieusonlam  Â·  6Comments

m-kad picture m-kad  Â·  3Comments

eicca picture eicca  Â·  3Comments

willsr picture willsr  Â·  5Comments