Skip to content

native: support aliased Meta Query self joins - #378

Closed
chubes4 wants to merge 3 commits into
mainfrom
fix/terra-mdi-373-20260908
Closed

chubes4 wants to merge 3 commits into
mainfrom
fix/terra-mdi-373-20260908

Conversation

@chubes4

@chubes4 chubes4 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • accept arbitrary AND/OR ON predicates and cross-alias equality/range comparisons
  • evaluate ON before LEFT JOIN null extension, then apply WHERE to joined rows
  • materialize aliased parenthesized SELECT, UNION, and UNION ALL sources in FROM and JOIN
  • preserve SQL UNION DISTINCT sequencing after UNION ALL and bound indexed join fan-out by actual candidate pairs
  • add raw and WordPress WP_Query multi-alias Meta Query coverage

Verification

  • php tests/smoke-native-join-query.php
  • php tests/smoke-native-subquery-union.php
  • php tests/smoke-native-option-query.php
  • PHP lint and git diff --check
  • isolated Lab checkout: complete tests/smoke-*.php sweep
  • isolated Lab WordPress Codebox: MDI_WP_CODEBOX_BIN="$HOME/.local/bin/wp-codebox" php tests/run-native-mysql-coverage.php
    • 38/38 statements and 26/26 operations supported

Notes

Generic non-equality joins use a 100,000 candidate-pair cost limit; equality joins retain indexed lookup behavior and now count actual fan-out. The sibling #372 scalar review is independent.

AI assistance

Implemented and tested with OpenAI GPT-5.6 Terra (openai/gpt-5.6-terra) via OpenCode. I extended the typed parser, query contracts, and native executor; independently audited SQL result semantics; added behavioral regressions; and ran local, isolated Lab smoke, and WordPress Codebox validation.

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