A
A
Anton Ivanov2014-06-01 13:02:07
PostgreSQL
Anton Ivanov, 2014-06-01 13:02:07

How to add element to json array in PostgreSQL 9.3?

Hello.
There is a field in the table with json type. There is always an array of objects. It is necessary to add one more element to this array in one update, that is, without reading the row from the table in advance.
Didn't find a solution. Most likely, the fact is that in json in general there will not always be an array of objects.
I can’t use json[] for reasons that doctrine is not friendly with this type.
Well, or you need to teach doctrine to understand this type :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimitriy, 2014-06-01
@Vakiliy

If done purely by postgres, then either update the entire field, or use a function to update, for example, like this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question