ITADN

`DELETE ... RETURNING` result not camel cased

#1157Openkarlhorky 创建于 2026-03-05
K
karlhorkycommented
Hi @porsager, hope things are good! 👋 It appears that `postgres.camel` is not working with `DELETE ... RETURNING` queries? 🤔 Or am I doing something wrong? Config: ```ts const postgresJsConfig = { ssl: Boolean(process.env.POSTGRES_URL), transform: { ...postgres.camel, undefined: null, }, }; ``` Query: ```ts export const deleteAnimalInsecure = cache( async (animalToDelete: Pick<Animal, 'id'>) => { const [animal] = await sql<Animal[]>` DELETE FROM animals WHERE id = ${animalToDelete.id} RETURNING animals.* `; return animal; }, ); ``` Result (snake case): ```json { "animal": { "id": 3, "first_name": "Trevor", "type": "iguana", "accessory": "plastic fork collection", "birth_date": "2020-08-17T00:00:00.000Z" } } ``` Expected result (camel case): ```json { "animal": { "id": 3, "firstName": "Trevor", "type": "iguana", "accessory": "plastic fork collection", "birthDate": "2020-08-17T00:00:00.000Z" } } ``` Camel case results are returned for other `RETURNING` queries such as `UPDATE ... RETURNING` queries (as well as other non-`RETURNING` queries such as `SELECT` queries): ```ts export const updateAnimalInsecure = cache(async (updatedAnimal: Animal) => { const [animal] = await sql<Animal[]>` UPDATE animals SET first_name = ${updatedAnimal.firstName}, type = ${updatedAnimal.type}, accessory = ${updatedAnimal.accessory}, birth_date = ${updatedAnimal.birthDate} WHERE id = ${updatedAnimal.id} RETURNING animals.* `; return animal; }); ```
0 条评论