fix tests

This commit is contained in:
Hongbo Wu 2023-12-22 17:12:24 +08:00
parent ccec94dae0
commit c21ba9e11f

View file

@ -73,17 +73,13 @@ export const labelRepository = appDataSource.getRepository(Label).extend({
},
createLabels(labels: CreateLabelInput[], userId: string) {
return this.query(
`
INSERT INTO omnivore.labels (user_id, name, color, description, internal)
SELECT $1, $2, $3, $4, $5
WHERE NOT EXISTS (
SELECT 1 FROM omnivore.labels WHERE LOWER(name) = LOWER($2) AND user_id = $1
)
RETURNING id, name, color, description, created_at
`,
labels.map((l) => Object.values(convertToLabel(l, userId)))
) as Promise<Label[]>
return this.upsert(
labels.map((l) => convertToLabel(l, userId)),
{
conflictPaths: ['name', 'user'],
skipUpdateIfNoValuesChanged: true,
}
)
},
deleteById(id: string) {