feat(v2): refactor modular + cierre de SQL injection (Fase 0)#5
Merged
Conversation
Reorganización completa hacia un paquete `shiba` modular preparado para multi-dialecto, con compat shim `shibamysql`. Estructura - `shiba/core/` — QueryBuilder y TableBuilder agnósticos - `shiba/dialects/base.py` — contrato Dialect - `shiba/dialects/mysql/` — driver pymysql, quoting backtick, mapping de tipos - `shiba/errors.py` + `shiba/error_codes.py` — jerarquía tipada y catálogo SHIBA-XYZW con mapper desde excepciones del driver - `shiba/identifiers.py` — whitelist de identificadores y operadores Seguridad - Valores parametrizados en WHERE/JOIN/INSERT/UPDATE/DELETE - Identificadores citados y validados antes de concatenarse - ENUM y DEFAULT escapan comillas; delete() sin WHERE bloqueado Fixes de v1.x - `unique()` retorna self (rompía el fluent chain) - `_whereArray` ya no crashea con condición de 3 elementos - `build()` retorna self, errores son excepciones (no `print`) - Cursor por operación; transacciones explícitas con context manager - Context manager en `Database` y `ShibaConnection` Tooling - `pyproject.toml` reemplaza `setup.py`; soporte Python 3.10–3.13 - Ruff + mypy --strict + pytest configurados - 60 tests sin DB cubren builder, identificadores y error codes - CI con matriz 3.10–3.13 (ruff + mypy + pytest) Compatibilidad - `import shibamysql` sigue funcionando emitiendo DeprecationWarning - `MANINEFT.in` renombrado a `MANIFEST.in` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 18, 2026
ShibaRoPinoo
added a commit
that referenced
this pull request
May 18, 2026
Consolida en un solo commit el trabajo de los PRs #5–#9 (cuyas ramas quedaron divergentes tras varios force-pushes para fix de CI). El detalle por fase vive en los PRs cerrados. Fase 0 — Seguridad y estructura - Paquete `shiba/` modular con core/ agnóstico y dialects/. - SQL injection cerrada: valores parametrizados, identificadores validados y citados por dialecto. - Catálogo `SHIBA-XYZW` de error codes con mapper desde drivers. - Excepciones tipadas, transacciones explícitas, context manager. - `shibamysql/` shim deprecated. - Tooling: pyproject.toml, ruff, mypy --strict, pytest, CI. Fase 1 — Query builder rico - `or_where`, `where_in/not_in/null/not_null/like/between`, `where_group(callback)`, `where_json(col, path, value)`. - `group_by`, `having`, `find`, `exists`, `pluck`, agregados. - `paginate`, `chunk`, `iterate`. - `upsert(data, on=[...])`, `truncate`, `raw` escape hatch. Fase 1.5 — ORM híbrido tipado - `Model` con metaclass que lee anotaciones por MRO con `inspect.get_annotations(eval_str=True)`. - 12 subclases de `Field` (PrimaryKey, String, Json, DateTime, DecimalField, Enum, ForeignKey, ...) e inferencia automática. - `ModelQuery[T]` hidrata filas a instancias. - Conexión global (`set_default_connection`) o por clase (`__db__`). Fase 2 — PostgreSQL - Dialect con doble comilla, `JSONB`, `BYTEA`, `TIMESTAMP`, `GENERATED ALWAYS AS IDENTITY`, `ON CONFLICT DO UPDATE`. - Driver psycopg3 con import perezoso (dep opcional). - `shiba.connect("mysql://...")`/`postgres://...` factory. Fase 4 — Tests de integración - 7 tests sobre MySQL 8 y Postgres 16 con Testcontainers, marker `integration`, job CI separado. Stats - 114 unit tests + 7 integration verdes (39s end-to-end). - ruff y mypy --strict limpios sobre 25 archivos. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ShibaRoPinoo
added a commit
that referenced
this pull request
May 18, 2026
Consolida en un solo commit el trabajo de los PRs #5–#9 (cuyas ramas quedaron divergentes tras varios force-pushes para fix de CI). El detalle por fase vive en los PRs cerrados. Fase 0 — Seguridad y estructura - Paquete `shiba/` modular con core/ agnóstico y dialects/. - SQL injection cerrada: valores parametrizados, identificadores validados y citados por dialecto. - Catálogo `SHIBA-XYZW` de error codes con mapper desde drivers. - Excepciones tipadas, transacciones explícitas, context manager. - `shibamysql/` shim deprecated. - Tooling: pyproject.toml, ruff, mypy --strict, pytest, CI. Fase 1 — Query builder rico - `or_where`, `where_in/not_in/null/not_null/like/between`, `where_group(callback)`, `where_json(col, path, value)`. - `group_by`, `having`, `find`, `exists`, `pluck`, agregados. - `paginate`, `chunk`, `iterate`. - `upsert(data, on=[...])`, `truncate`, `raw` escape hatch. Fase 1.5 — ORM híbrido tipado - `Model` con metaclass que lee anotaciones por MRO con `inspect.get_annotations(eval_str=True)`. - 12 subclases de `Field` (PrimaryKey, String, Json, DateTime, DecimalField, Enum, ForeignKey, ...) e inferencia automática. - `ModelQuery[T]` hidrata filas a instancias. - Conexión global (`set_default_connection`) o por clase (`__db__`). Fase 2 — PostgreSQL - Dialect con doble comilla, `JSONB`, `BYTEA`, `TIMESTAMP`, `GENERATED ALWAYS AS IDENTITY`, `ON CONFLICT DO UPDATE`. - Driver psycopg3 con import perezoso (dep opcional). - `shiba.connect("mysql://...")`/`postgres://...` factory. Fase 4 — Tests de integración - 7 tests sobre MySQL 8 y Postgres 16 con Testcontainers, marker `integration`, job CI separado. Stats - 114 unit tests + 7 integration verdes (39s end-to-end). - ruff y mypy --strict limpios sobre 25 archivos. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Primera fase del roadmap hacia Shiba v2: reorganización modular y endurecimiento. Sin cambios funcionales más allá del fluent restaurado.
shiba/concore/(builders agnósticos) ydialects/mysql/(driver pymysql).shibamysqlqueda como shim deprecated que reexporta y emiteDeprecationWarning.SHIBA-XYZWcon mapper desde excepciones nativas del driver, accesible víae.codeen cualquierShibaError.Seguridad
%s); identificadores siempre por whitelist + backticks.delete()sin WHERE se rechaza.Fixes de v1.x
unique()ahora retornaself(rompía el chain)._whereArrayya no crashea con condición de 3 elementos.build()retornaself, errores tipados (noprint).transaction()context manager.Tooling
pyproject.tomlreemplazasetup.py. Soporte Python 3.10–3.13.--strict+ pytest configurados.Test plan
ruff check .limpiomypylimpio (17 archivos)pytest -q60/60import shibamysqldesde un proyecto v1 y verificarDeprecationWarning🤖 Generated with Claude Code