max_rows rewrites the offset of `LIMIT offset, count` on MySQL/MariaDB/SQLite

Abierto Apto para principiantes
#536 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
mariadb, mysql, sql, sqlite, typescript

Línea de trabajo

Empieza por findTopLevelLimit en src/utils/sql-row-limiter.ts, que, según indica el issue, lee el primer número después de LIMIT como el recuento de filas. Revisa las pruebas existentes del limitador de filas y añade cobertura para LIMIT offset, count y LIMIT count OFFSET offset en SQLite y MySQL. La tarea estará completa cuando se conserve el offset, las filas devueltas estén limitadas a max_rows y se informe del truncamiento cuando corresponda.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

With max_rows set on a tool, a query in the LIMIT offset, count form gets a different page of rows, or more rows than the cap.

[[sources]]
id = "lite"
dsn = "sqlite:///w/t.db"

[[tools]]
name = "execute_sql"
source = "lite"
max_rows = 5

Table t(id) with ids 1..300, on v2.0.0 (main c3b3fc7):

query sqlite3 dbhub
select id from t order by id limit 100, 3 101, 102, 103 7, 8, 9
select id from t order by id limit 3, 10 4 .. 13 4 .. 13 (10 rows, over max_rows = 5, not marked truncated)
select id from t order by id limit 3 offset 100 101, 102, 103 101, 102, 103

Same on MySQL 8. No error in either case, so the agent works with the wrong rows.

findTopLevelLimit in src/utils/sql-row-limiter.ts reads the first number after LIMIT as the row count, but in LIMIT a, b that is the offset. The limiter then replaces it with min(a, max_rows + 1) (100 becomes 6), and when a is already under the cap it leaves the query alone, so b is never capped.

#444 had a fix for this and was closed with a request to open an issue first; I didn't find one, so here it is. I can send a PR that caps the second operand of LIMIT a, b and keeps the offset, if that's the direction you want.

Lenguaje dominante
TypeScript
Estrellas
3.9k
Forks
338
Merge medio
6 h 35 min
PR fusionados (30 d)
37

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bytebase/dbhub

Todos los issues de bytebase/dbhub

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.