Skip to content

Add support for other hydration mode in QueryResultDynamicReturnTypeExtension #403

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

Closed
VincentLanglet opened this issue Dec 26, 2022 · 1 comment · Fixed by #404
Closed

Comments

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Dec 26, 2022

I think we can "easily" improve the QueryResultDynamicReturnTypeExtension to supports more than HYDRATE_OBJECT.

Click here to see the different hydration modes
  • HYDRATE_OBJECT: Default behavior, return the result without modifications.

  • HYDRATE_ARRAY: Every object are transformed to an array, so

array<array{id: int, language: string}>

is untouched, but

array<array{id: int, user: User}>

would be transformed to

array<array{id: int, user: array{username: ..., email:..., ....}}>
  • HYDRATE_SCALAR: Kinda like the HYDRATE_ARRAY, but everything is merged inside a single array, so
array<array{id: int, language: string}>

is untouched, but

array<array{id: int, user: User}>

would be transformed to

array<array{id: int, u_username: ..., u_email:..., ....}>
  • HYDRATE_SINGLE_SCALAR: Kinda like the HYDRATE_SCALAR, but only one key inside the array will be supported
array<array{id: int}>

is untouched, but

array<array{user: User}>

would be transformed to

array<array{u_username: ...}> // Only if there is only one property inside the object
  • HYDRATE_SCALAR_COLUMN: Kinda like the HYDRATE_SINGLE_SCALAR, but the single-array element is replaced by the element.
array<array{id: int}>

is changed to

array<int>
  • HYDRATE_SIMPLEOBJECT: I don't really know this one.

I would say that good steps would be

  • Infer the result when there is no object inside the result (for most of the hydration mode it's like HYDRATE_OBJECT)
  • Infer the result when there is an object inside the result by replacing to array<string, mixed>
@VincentLanglet VincentLanglet changed the title Add support for other QueryResultDynamicReturnTypeExtension Add support for other hydration mode in QueryResultDynamicReturnTypeExtension Dec 26, 2022
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant