Skip to content

Fix mixed row inference for CTE (WITH ...) queries#776

Open
vaielab wants to merge 2 commits into
staabm:mainfrom
vaielab:cte
Open

Fix mixed row inference for CTE (WITH ...) queries#776
vaielab wants to merge 2 commits into
staabm:mainfrom
vaielab:cte

Conversation

@vaielab
Copy link
Copy Markdown
Contributor

@vaielab vaielab commented May 17, 2026

Fix row inference for queries starting with WITH [RECURSIVE].

The issue caused iterated rows to be inferred as mixed instead of the expected typed array shape, because getQueryType() did not recognise CTE queries as SELECT-equivalent and bailed out before reaching the reflector.

Changes:

  • add regression coverage for the CTE path (simple, multi, recursive, aggregation, SELECT *, FETCH_NUM)
  • update QueryReflection::getQueryType() to skip past CTE definitions and return the inner statement keyword

Result:
foreach ($stmt as $row) now keeps the expected inferred array type for WITH cte AS (...) SELECT ... FROM cte queries.

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

Successfully merging this pull request may close these issues.

1 participant