cloudflare / cloudflare/developer-platform
🐛 BUG: D1 Database triggers bypass D1 data type validation
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 1
- Forks
- 0
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### Which Cloudflare product(s) does this pertain to?
D1
### What version(s) of the tool(s) are you using?
3.53.1 [Wrangler]
### What version of Node are you using?
_No response_
### What operating system and version are you using?
Mac Ventura 13.5.2
### Describe the Bug
### Observed behavior
Triggers can bypass column data type validation when updating a row
### Expected behavior
Triggers should be restricted by a column's data type when performing updates
### Steps to reproduce
- Setup:
```sql
CREATE TABLE IF NOT EXISTS test (
id TEXT PRIMARY KEY NOT NULL,
val INTEGER NOT NULL
);
CREATE TRIGGER update_on_change AFTER
UPDATE OF val ON test FOR EACH ROW
BEGIN
UPDATE test
SET
val = 'not_an_integer'
WHERE
id = NEW.id;
END;
INSERT INTO test (id, val) VALUES ('test', 1);
```
- Trigger the trigger:
```sql
UPDATE test SET val=2 WHERE id='test'
```
- the `val` column of the `test` row (`val` is defined as an Integer) now contains Text
### Please provide a link to a minimal reproduction
_No response_
### Please provide any relevant error logs
_No response_
Guía de contribución
Línea de trabajo
Comienza con la reproducción SQL de este issue usando D1 y Wrangler 3.53.1, y verifica si el trigger almacena texto en la columna INTEGER. Rastrea la ruta de actualización del trigger de D1 y su validación del tipo de datos; después, confirma que la misma actualización rechaza 'not_an_integer' y conserva el tipo de la columna.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- sql
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100