Skip to content

feat(v2): query builder rico — UPDATE+, UPSERT, JSON, paginate (Fase 1)#6

Merged
ShibaRoPinoo merged 1 commit into
feature/fase-0-hardeningfrom
feature/fase-1-query-rico
May 18, 2026
Merged

feat(v2): query builder rico — UPDATE+, UPSERT, JSON, paginate (Fase 1)#6
ShibaRoPinoo merged 1 commit into
feature/fase-0-hardeningfrom
feature/fase-1-query-rico

Conversation

@ShibaRoPinoo
Copy link
Copy Markdown
Owner

Resumen

Continúa la v2 sobre el QueryBuilder ya saneado en #5. Sólo añade — no rompe API existente.

  • WHERE: or_where, where_in/not_in/null/not_null/like/between, where_group(callback) y where_json(col, path, value) con validación de path.
  • Lectura: group_by, having, find, exists, pluck, agregados (sum/avg/min/max).
  • Paginación: paginate(page, per_page), chunk(size, cb), iterate().
  • Mutaciones: upsert (compilado por el dialecto: MySQL → ON DUPLICATE KEY UPDATE), truncate.
  • Database.raw / ShibaConnection.raw como escape hatch.

Dialect

Nuevo método abstracto compile_upsert_update(cols). La firma queda lista para Postgres (ON CONFLICT DO UPDATE) en la Fase 2.

Test plan

  • 24 tests nuevos sin DB cubren cada operador, agrupaciones, agregados, paginate, chunk, upsert, JSON path validation
  • Regresión de Fase 0: los 60 tests previos siguen verdes
  • ruff + mypy limpios
  • Smoke test contra MySQL real → llegará con el PR de Testcontainers (Fase 4 de la cadena)

PR apilado sobre feature/fase-0-hardening. Hacer merge tras #5.

🤖 Generated with Claude Code

…ming (Fase 1)

Amplía `QueryBuilder` con la API que ya espera cualquier usuario que
viene de Laravel/Knex.

WHERE
- `or_where`, `where_in`, `where_not_in`, `where_null`, `where_not_null`,
  `where_like`, `where_between`.
- `where_group(callback)` para mezclar AND/OR entre paréntesis.
- `where_json(col, '$.path', value)` con validación estricta del path.

Lectura
- `group_by`, `having`.
- `find(pk)`, `first()`, `exists()`, `pluck(col)`.
- `count`, `sum`, `avg`, `min`, `max` con WHERE/GROUP/HAVING heredados.

Paginación / streaming
- `paginate(page, per_page)` devuelve `{page, per_page, total, last_page, data}`.
- `chunk(size, callback)` procesa por lotes; `iterate()` como generator.

Mutaciones
- `upsert(data, update=[...])` — el dialecto compila la cláusula
  (MySQL → `ON DUPLICATE KEY UPDATE col = VALUES(col)`).
- `truncate()` para vaciar tabla.

Driver
- `Database.raw(query, params)` como escape hatch documentado, expuesto
  también en `ShibaConnection.raw`.

Dialect
- Nueva abstracta `compile_upsert_update(cols)` en `Dialect`.

Tests
- 24 nuevos casos cubren todas las variantes + regresión del
  comportamiento existente. Total: 84/84.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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