feat(v2): query builder rico — UPDATE+, UPSERT, JSON, paginate (Fase 1)#6
Merged
Merged
Conversation
…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>
3 tasks
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumen
Continúa la v2 sobre el
QueryBuilderya saneado en #5. Sólo añade — no rompe API existente.or_where,where_in/not_in/null/not_null/like/between,where_group(callback)ywhere_json(col, path, value)con validación de path.group_by,having,find,exists,pluck, agregados (sum/avg/min/max).paginate(page, per_page),chunk(size, cb),iterate().upsert(compilado por el dialecto: MySQL →ON DUPLICATE KEY UPDATE),truncate.Database.raw/ShibaConnection.rawcomo 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
ruff+mypylimpios🤖 Generated with Claude Code