Skip to content

Add MySQL and MariaDB dialect query builders#1

Merged
hlubek merged 40 commits into
mainfrom
mysql-mariadb
Jul 1, 2026
Merged

Add MySQL and MariaDB dialect query builders#1
hlubek merged 40 commits into
mainfrom
mysql-mariadb

Conversation

@hlubek

@hlubek hlubek commented Jun 30, 2026

Copy link
Copy Markdown
Member

No description provided.

hlubek and others added 30 commits June 30, 2026 23:10
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… set ops, CTE, lateral)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ative comments

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ing comments)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ions, no cross-dialect comment framing)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…chema+storage/pretty/randomBytes); functions ledger
…er/combination/lock); widen cross-dialect select type hints
…aDB\Q facade; shared BuildsExpressions facade trait
…TURNING (VALUES upsert, no AS new); UPDATE shared
…eDialect, QueryBuilder::withValidateTarget) — validation-only, rendering unchanged
…e MariaDB\, version-aware requireDialect gates, InsertValuesBuilder as()/Q::values, differences test corpus)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ers and BuildsExpressions/SharedFunctions into Q/Q\Func

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ysql-mariadb.md rewrite, README/AGENTS, design-doc status header)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… (both engines, render + validation); drop pre-collapse FunctionsMysqlOnlyTest

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…at literal call sites

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hlubek and others added 10 commits July 1, 2026 14:38
… precedence rescale; AGENTS note — Q\Func returns Exp, FROM-only constructs live on Q

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ray), parenthesized RHS)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…deredSetAggBuilder->withinGroup()->orderBy()->desc()->over(), mirroring the PG canonical shape

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Builder implements FromExp, column()/columnForOrdinality())

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Supported in §12 ledger; update usage-doc operators/functions + Limitations

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…->columns(closure); path()/existsPath()/forOrdinality()/on-empty+on-error/nested()->path()->columns(); docs updated (ledger, usage example, limitations)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ocument validation-error categories in AGENTS.md

- tests/MySQL SelectJsonShapeTest: JSON_OBJECT / JSON_ARRAYAGG / JSON_OBJECTAGG
  selection shapes (nested objects, roll-ups via join+GROUP BY, correlated
  subselects, COALESCE(...,JSON_ARRAY()) empty-array idiom), grounded in the
  MySQL 8.4 reference
- AggBuilder: gate DISTINCT to the aggregates whose grammar accepts it
  (AVG/COUNT/MAX/MIN/SUM) via $sb->addError when validating; doc-cited allow-list
- FunctionsTest: accepted/rejected DISTINCT + withoutValidation() bypass;
  ExpressionsTest: comparison/arithmetic/unary/REGEXP/junction/ANY-ALL coverage
- AGENTS.md: new "Validation errors" section — advisory value checks gate on
  isValidating() and keep rendering; mutually-exclusive builder state always throws

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add tests for previously-uncovered API surface: expression operators, function
facades, join/lateral/set-op/CTE/window builder methods, DML alias & RETURNING
paths, MySQL named-arg binding (new ArgsTest), and validation branches (empty
CASE, invalid identifier/type, values+query / ON CONFLICT constraint+targets).
Regroup the MySQL SELECT test nest-by-clause to match PostgreSQL. Document the
coverage tooling and intentionally-uncovered set in AGENTS.md, and add the
xdebug extension to devbox so coverage runs out of the box.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…on/GroupConcat) (→ 99%)

- MySQL Keywords: backtick-quoted part in a dotted identifier
- MySQL Requirement: version-window satisfiedBy upper bound + describe() variants (new RequirementTest)
- PostgreSQL WindowDefinition: named window refining another, multi-key PARTITION BY
- MySQL GroupConcatBuilder: multiple expressions and multiple ORDER BY keys

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bring the MySQL family to parity with the PostgreSQL builder for JSON
construction, and restructure the README around both dialect families.

JSON object builder:
- Q\Func::jsonObject() now returns an immutable JsonObjectBuilder
  (prop/propIf/applyIf/unset) rendering JSON_OBJECT(...), replacing the
  varargs passthrough. Computed keys stay on the Q::func('JSON_OBJECT', ...)
  escape hatch.

JSON-first entry point:
- Q::selectJson()/applySelectJson()/as() make a JSON object the query's
  first select element, via a new SelectJsonSelectBuilder and selectJson /
  selectJsonAlias threaded through SelectQueryParts, derive() and
  writeSelectParts().

The prop-builder pattern is shared architecture, not a PG SQL feature, so
the name and SQL stay dialect-native (jsonObject / JSON_OBJECT).

README: rewritten as a balanced two-dialect hub — shared philosophy,
dialect overview, intermixed per-engine examples with an index, and a
prominent "MySQL & MariaDB: one builder, two engines" section covering
construction-determined rendering and opt-in target validation. composer.json
now advertises MySQL/MariaDB.

Tests: ported the PostgreSQL JsonBuildObject/JsonQuery suites to the MySQL
family. 664 pass, PHPStan level max clean, new builders 100% covered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hlubek hlubek marked this pull request as ready for review July 1, 2026 17:23
@hlubek hlubek merged commit 403f230 into main Jul 1, 2026
3 checks passed
@hlubek hlubek deleted the mysql-mariadb branch July 1, 2026 17:25
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