mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +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:
@@ -29,7 +29,7 @@ export const collabNoteUpdateRequestSchema = z.object({
|
||||
content: z.string().nullable().optional(),
|
||||
category: z.string().nullable().optional(),
|
||||
color: z.string().nullable().optional(),
|
||||
pinned: z.union([z.boolean(), z.number()]).optional(),
|
||||
pinned: z.union([z.boolean(), z.number().int()]).optional(),
|
||||
website: z.string().nullable().optional(),
|
||||
});
|
||||
export type CollabNoteUpdateRequest = z.infer<typeof collabNoteUpdateRequestSchema>;
|
||||
@@ -44,7 +44,7 @@ export const collabPollCreateRequestSchema = z.object({
|
||||
export type CollabPollCreateRequest = z.infer<typeof collabPollCreateRequestSchema>;
|
||||
|
||||
export const collabPollVoteRequestSchema = z.object({
|
||||
option_index: z.number(),
|
||||
option_index: z.number().int(),
|
||||
});
|
||||
export type CollabPollVoteRequest = z.infer<typeof collabPollVoteRequestSchema>;
|
||||
|
||||
@@ -57,14 +57,14 @@ const httpUrl = z.url().refine((value) => /^https?:\/\//i.test(value.trim()), 'A
|
||||
export const collabLinkCreateRequestSchema = z.object({
|
||||
title: z.string().trim().min(1),
|
||||
url: httpUrl,
|
||||
pinned: z.union([z.boolean(), z.number()]).optional(),
|
||||
pinned: z.union([z.boolean(), z.number().int()]).optional(),
|
||||
});
|
||||
export type CollabLinkCreateRequest = z.infer<typeof collabLinkCreateRequestSchema>;
|
||||
|
||||
export const collabLinkUpdateRequestSchema = z.object({
|
||||
title: z.string().trim().min(1).optional(),
|
||||
url: httpUrl.optional(),
|
||||
pinned: z.union([z.boolean(), z.number()]).optional(),
|
||||
pinned: z.union([z.boolean(), z.number().int()]).optional(),
|
||||
});
|
||||
export type CollabLinkUpdateRequest = z.infer<typeof collabLinkUpdateRequestSchema>;
|
||||
|
||||
@@ -73,7 +73,7 @@ export type CollabLinkUpdateRequest = z.infer<typeof collabLinkUpdateRequestSche
|
||||
export const collabMessageCreateRequestSchema = z.object({
|
||||
text: z.string().max(5000).optional(),
|
||||
// Multipart fields arrive as strings; JSON chat still sends a number/null.
|
||||
reply_to: z.union([z.number(), z.string(), z.null()]).optional(),
|
||||
reply_to: z.union([z.number().int(), z.string(), z.null()]).optional(),
|
||||
});
|
||||
export type CollabMessageCreateRequest = z.infer<typeof collabMessageCreateRequestSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user