Hi
I am working on
PostgreSQL with a verticalized table
table1
_____________________________________
| id | client | description | value |
| 2 | 1 | name | user1 |
| 4 | 2 | name | user2 |
Select client jsonb_object_agg(description,value) as val from table1
this query on
PostgreSQL return
____________________________________________
the first column is an int and the second is a Json
but with pewee
data = table1.select(table1.client ,
fn.jsonb_object_agg(
table1.description,
table1.value).alias('val'))
.group_by(table1.client ).dicts().first()
return
[
{ 'client' : 1 , 'val' : '{"email":"
c...@mail.com","name":"user1" } '},
{ 'client' : 2 , 'val' : '{"email":"
a...@mail.com","name":"user2" } '},
]
so the problem is that val is an string instead of a JSON does exist a way to change the type of the column val to JSON I tryed to use cast but I have the same result a string with the Json