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

Is postgres json_agg supported ? #3150

Closed
mmaryo opened this issue Sep 11, 2023 · 3 comments
Closed

Is postgres json_agg supported ? #3150

mmaryo opened this issue Sep 11, 2023 · 3 comments

Comments

@mmaryo
Copy link

mmaryo commented Sep 11, 2023

Hello,

With Java 17 and Spring Boot 3 project

I'm trying to get data into an object CompleteUserTeam for this request (and if I change it to String I can see the result inside)

    @Query(value = """
            select u.*,
                   (select json_agg(t.*)
                    from team t
                    where u.id  = t.lead_id) as team
            from "user" u
            where u.tenant_id = :tenantId
            limit 50;
            """, nativeQuery = true)
    List<CompleteUser> findAllCompleteUsersByTenantId(@Param("tenantId") UUID tenantId);


public interface CompleteUser {
    UUID getId();
    String getEmail();
    String getFirst_Name();
    List<CompleteUserTeam> getTeam();
}

interface CompleteUserTeam {
    UUID getId();
    String getName();
}

There is no error in logs but the output is cut with half ok half error 500

[
    {
        "title": "CEO",
        "id": "a541c58b-8a25-4feb-8dda-46ced91c49ca",
        "initials": null,
        "avatar": "users/app/tom_rcdk52",
        "team": [
            {}
        ]
    }
]{
    "type": "about:blank",
    "title": "Internal Server Error",
    "status": 500,
    "detail": "Failed to write request",
    "instance": "/users",
    "properties": null
}

Any idea ?

@gregturn
Copy link
Contributor

Basically, to debug this, you need to capture the outputs to see what the final query is that was actually sent over to Postgres. It's possible that some bits of it were lost by QueryUtils since this query is quite complex, including a correlated subquery.

If QueryUtils is losing bits of it, then you may need to leverage the same solution as suggested in #3151.

@gregturn gregturn added the status: waiting-for-feedback We need additional information before we can continue label Sep 11, 2023
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Sep 18, 2023
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Sep 25, 2023
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

3 participants