- Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Am I the only one encountering this kind of generated query? I've tried using this query, but it doesn't work because it throws an error requiring the type to be numeric.
Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''100' offset '0' Query:
-- name: AcmeGetThreadsIDsByUpdatedAtLimitOffsetQuery :many SELECT id FROM threads WHERE updated_at BETWEEN sqlc.arg('min_updated_at') AND sqlc.arg('max_updated_at') order by id asc limit ? offset ?; Generated:
export const acmeGetThreadsIDsByUpdatedAtLimitOffsetQueryQuery = `-- name: AcmeGetThreadsIDsByUpdatedAtLimitOffsetQuery :many SELECT id FROM threads WHERE updated_at BETWEEN ? AND ? order by id asc limit ? offset ?`; export interface AcmeGetThreadsIDsByUpdatedAtLimitOffsetQueryArgs { minUpdatedAt: Date; maxUpdatedAt: Date; limit: string; offset: string; } export interface AcmeGetThreadsIDsByUpdatedAtLimitOffsetQueryRow { id: number; } export async function acmeGetThreadsIDsByUpdatedAtLimitOffsetQuery(client: Client, args: AcmeGetThreadsIDsByUpdatedAtLimitOffsetQueryArgs): Promise<AcmeGetThreadsIDsByUpdatedAtLimitOffsetQueryRow[]> { const [rows] = await client.query<RowDataPacket[]>({ sql: seekingGetThreadsIDsByUpdatedAtLimitOffsetQueryQuery, values: [args.minUpdatedAt, args.maxUpdatedAt, args.limit, args.offset], rowsAsArray: true }); return rows.map(row => { return { id: row[0] }; }); } Interim Solution:
By forcing my input limit from being a number then casting it as unknown then string, just faking it to be string!
acmeGetThreadsIDsByUpdatedAtLimitOffsetQuery(client, { // ..., limit: limit as unknown as string, offset: offset as unknown as string, }); Metadata
Metadata
Assignees
Labels
No labels