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

Use the datasource type within queries to unmarshal them in PHP #569

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .config/ci/php/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ parameters:
- identifier: identical.alwaysFalse # not a big deal, duplicated enum values come from the schema
paths:
- ../../../generated/php/src/Common/ScaleDirection.php
- identifier: offsetAccess.nonOffsetAccessible
paths:
- ../../../generated/php/src/Cog/Runtime.php
5 changes: 5 additions & 0 deletions internal/jennies/php/templates/runtime/runtime.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ final class Runtime
*/
public function dataqueryFromArray(array $data, string $dataqueryTypeHint): Dataquery
{
// Dataqueries might reference the datasource to use, and its type. Let's use that.
if (empty($dataqueryTypeHint) && !empty($data['datasource']) && !empty($data['datasource']['type'])) {
$dataqueryTypeHint = $data['datasource']['type'];
}

// A hint tells us the dataquery type: let's use it.
if (!empty($dataqueryTypeHint) && isset($this->dataqueryVariants[$dataqueryTypeHint])) {
$fromArray = $this->dataqueryVariants[$dataqueryTypeHint]->fromArray;
Expand Down
6 changes: 2 additions & 4 deletions testdata/generated/cog/variants/variants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.