Skip to content

feat(database): add selectRaw, whereRaw, and orderByRaw to QueryBuilderInterface#78

Open
michalbiarda wants to merge 2 commits into
marko-php:developfrom
michalbiarda:feature/query-builder-raw-select-where
Open

feat(database): add selectRaw, whereRaw, and orderByRaw to QueryBuilderInterface#78
michalbiarda wants to merge 2 commits into
marko-php:developfrom
michalbiarda:feature/query-builder-raw-select-where

Conversation

@michalbiarda
Copy link
Copy Markdown

Summary

  • Adds selectRaw(string, array): static and whereRaw(string, array): static to QueryBuilderInterface with positional-binding support and denylist validation (;, --, /*, */, backtick)
  • Adds orderByRaw(string, string): static to QueryBuilderInterface for raw ORDER BY expressions
  • Implements all three methods in MySqlQueryBuilder, PgSqlQueryBuilder, and RepositoryQueryBuilder
  • whereRaw is honored by aggregate methods (count, min, max, sum, avg); selectRaw is ignored by aggregates (they replace the SELECT list entirely)
  • Binding order guaranteed: SELECT-raw bindings come before WHERE bindings in the compiled array

Test plan

  • QueryBuilderInterfaceTest — reflection-based contract assertions for all new methods
  • MySqlQueryBuilderTest — SQL compilation, binding order, denylist, aggregate path
  • PgSqlQueryBuilderSelectRawWhereRawTest — mirror of MySQL tests for PgSql
  • RepositoryQueryBuilderEnhancedTest — delegation and exception propagation
  • tests/Integration/QueryBuilderRawConsistencyTest — cross-driver binding-order and SQL-structure parity
  • Full suite: composer test green (5208 passed)

Closes #77

🤖 Generated with Claude Code

Adds `selectRaw(string, array): static` and `whereRaw(string, array): static`
to QueryBuilderInterface with positional-binding support, denylist validation
(blocks ;, --, /*, */, backtick), and implementations in MySqlQueryBuilder,
PgSqlQueryBuilder, and RepositoryQueryBuilder. Aggregate methods (count, min,
max, sum, avg) honor whereRaw conditions; selectRaw is ignored by aggregates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label May 19, 2026
…og entry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add selectRaw, whereRaw, and orderByRaw to QueryBuilderInterface

1 participant