Sanitizing misidentifies diamond-shaped references as cycles
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 57/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- database
Línea de trabajo
Reproduce el caso de creación con forma de diamante del issue y, después, inspecciona el método sanitize interno dentro de #sanitizeInitialValues. Verifica que sanitizar registros compartidos a través de ambas rutas hermanas deje definidos tanto author.profile como editor.profile.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
This is a very similar issue to #348, but occurs when the same record is referenced from two different paths in a create call.
For example, this code results in the same type of validation error as #348:
import { Collection } from '@msw/data';
import * as v from 'valibot';
const profileSchema = v.object({
id: v.string(),
bio: v.string(),
});
const userSchema = v.object({
id: v.string(),
name: v.string(),
get profile() { return profileSchema; },
});
const postSchema = v.object({
id: v.string(),
title: v.string(),
get author() { return userSchema; },
get editor() { return userSchema; },
});
const profiles = new Collection({ schema: profileSchema });
const users = new Collection({ schema: userSchema });
const posts = new Collection({ schema: postSchema });
users.defineRelations({ one }) => ({ profile: one(profiles) }));
posts.defineRelations({ one }) => ({
author: one(users),
editor: one(users),
}));
const profile = await profiles.create({ id: 'p1', bio: 'hi' });
const user = await users.create({ id: 'u1', name: 'Alice', profile });
// Diamond: same user referenced from two sibling fields
await posts.create({
id: 'post1',
title: 'Hello',
author: user,
editor: user,
});
In this setup, either author.profile or editor.profile will be undefined after sanitization.
From my testing, I've been able to fix the error by adding the following to the inner sanitize method within the #sanitizeInitialValues method:
const result = Object.fromEntries(...);
if (record && !isRevisit) {
visited.delete(record[kPrimaryKey]);
}
return result;
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.1k
- Forks
- 66
- Merge medio
- 3 min
- PR fusionados (30 d)
- 2
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mswjs/data
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
-
potentially resolved
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
-
Non-nullable self-referencing relationsPosiblemente ocupada @kettanaito la tomó hace 373 días. Abierto
Todos los issues de mswjs/data
Issues similares
-
ui(ListToolbar): search takes the full row on a phone instead of sharing it with the result countAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
priority:high
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
immich-app/immich#32426 ·
Los mantenedores suelen responder en 1 día
-
documentation good first issue hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
libredb/libredb-studio#1756 ·
Los mantenedores suelen responder en 1 día