mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
fix(db): refuse a fraction for an integer column at the request boundary
Every integer column is bigint on Postgres. SQLite stored a fraction sent to one (a packing quantity of 1.5, a budget item for 2.5 days, an id of 3.5) as a REAL, while Postgres rounded it in a statement MikroORM renders and refused it with a 500 in a Kysely statement, so the engines held different data for the same request. The request schemas of those fields now take whole numbers only, and INTCOL (tests/unit/contracts/integer-columns.test.ts) holds the class: it reads the integer columns from the entities and fails on any DTO field or inline MCP tool field of that name that takes any number.
This commit is contained in:
@@ -102,9 +102,9 @@ export const packingCreateItemRequestSchema = z.object({
|
||||
checked: z.union([z.boolean(), z.number().int().min(0).max(1)]).optional(),
|
||||
// Same shapes as the update schema below (#2154) — the create route used to
|
||||
// strip these three silently, forcing a second write to set them.
|
||||
weight_grams: z.number().nullable().optional(),
|
||||
bag_id: z.number().nullable().optional(),
|
||||
quantity: z.number().optional(),
|
||||
weight_grams: z.number().int().nullable().optional(),
|
||||
bag_id: z.number().int().nullable().optional(),
|
||||
quantity: z.number().int().optional(),
|
||||
// Mark the new item private to its creator (#858, legacy flag).
|
||||
is_private: z.boolean().optional(),
|
||||
// Three-tier sharing (#858): which list the item belongs to, and — for 'shared' —
|
||||
@@ -133,9 +133,9 @@ export const packingUpdateItemRequestSchema = z.object({
|
||||
// The legacy route accepted both boolean and 0/1 for checked — both stay valid.
|
||||
checked: z.union([z.boolean(), z.number().int().min(0).max(1)]).optional(),
|
||||
category: z.string().optional(),
|
||||
weight_grams: z.number().nullable().optional(),
|
||||
bag_id: z.number().nullable().optional(),
|
||||
quantity: z.number().optional(),
|
||||
weight_grams: z.number().int().nullable().optional(),
|
||||
bag_id: z.number().int().nullable().optional(),
|
||||
quantity: z.number().int().optional(),
|
||||
// Count packed pieces of a multi-piece item (#2296). Reaching the quantity
|
||||
// checks the item; null or 0 clears the count. Ticking `checked` resets it.
|
||||
packed_quantity: z.number().int().min(0).max(999).nullable().optional(),
|
||||
@@ -158,15 +158,15 @@ export const packingCreateBagRequestSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
color: z.string().optional(),
|
||||
// Same shape as the update schema below (#2154) — POST used to strip it.
|
||||
weight_limit_grams: z.number().nullable().optional(),
|
||||
weight_limit_grams: z.number().int().nullable().optional(),
|
||||
});
|
||||
export type PackingCreateBagRequest = z.infer<typeof packingCreateBagRequestSchema>;
|
||||
|
||||
export const packingUpdateBagRequestSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
color: z.string().optional(),
|
||||
weight_limit_grams: z.number().nullable().optional(),
|
||||
user_id: z.number().nullable().optional(),
|
||||
weight_limit_grams: z.number().int().nullable().optional(),
|
||||
user_id: z.number().int().nullable().optional(),
|
||||
});
|
||||
export type PackingUpdateBagRequest = z.infer<typeof packingUpdateBagRequestSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user