Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting not decoded data when using ARRAY_AGG #75

Open
buraktabn opened this issue Dec 10, 2022 · 1 comment
Open

Getting not decoded data when using ARRAY_AGG #75

buraktabn opened this issue Dec 10, 2022 · 1 comment

Comments

@buraktabn
Copy link

I have the following SQL query using ARRAY_AGG.

select
  service.id,
  service.service,
  pro_service_category.*,
  ARRAY_AGG(pro_service_action.*) AS actions
FROM
  pro_service_action
  JOIN ...
 where sa.account_id  = @accountId and service.id =  @serviceId
group by 1,2,3

This query yields the following result in DBMS

[
  {
    ...,
    "actions": "{\"(11,16,Action 111,Action111 Description,true,1,0.0)\",\"(12,16,Action 112,Action 112 Description,false,2,50.0)\"}"
  }
]

However, when I query this in the dart, actions which is the result of the ARRAY_AGG returns a byte array.

final res = await connection.mappedResultsQuery(_getProServiceDetail, substitutionValues: {
  'accountId': accountId,
  'serviceId': request.id,
});

print(json.encode(res.first['']));
{"actions":[0,0,0,1,0,0,0,0,0,0,101,155,0,0,0,2,0,0,0,1,0,0,0,111,0,0,0,7,0,0,0,23,0,0,0,4,0,0,0,9,0,0,0,23,0,0,0,4,0,0,0,15,0,0,0,25,0,0,0,9,65,99,116,105,111,110,32,49,49,0,0,0,25,0,0,0,21,65,99,116,105,111,110,32,49,49,32,68,101,115,99,114,105,112,116,105,111,110,0,0,0,16,0,0,0,1,1,0,0,0,23,0,0,0,4,0,0,0,1,0,0,2,189,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,111,0,0,0,7,0,0,0,23,0,0,0,4,0,0,0,10,0,0,0,23,0,0,0,4,0,0,0,15,0,0,0,25,0,0,0,9,65,99,116,105,111,110,32,49,50,0,0,0,25,0,0,0,21,65,99,116,105,111,110,32,49,50,32,68,101,115,99,114,105,112,116,105,111,110,0,0,0,16,0,0,0,1,0,0,0,0,23,0,0,0,4,0,0,0,2,0,0,2,189,0,0,0,8,64,73,0,0,0,0,0,0]}

How can I decode this byte array to a human-readable format?

@isoos
Copy link
Owner

isoos commented Dec 10, 2022

Unfortunately not all postgres types have been implemented (contributions are welcome!).

However, in such cases, you may cast/transform the result object to JSON or some other string format at the server and parse it back on the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants