ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamโ€ข3y agoโ€ข
1 reply
Nxia618

numeric returns string when querying with Postgres

export const order = pgTable(
  'orders', {
  ...
  totalValue: numeric('total_value', { precision: 10, scale: 2 }),
  ...
})
export const order = pgTable(
  'orders', {
  ...
  totalValue: numeric('total_value', { precision: 10, scale: 2 }),
  ...
})

inspecting
order.totalValue
order.totalValue
I get type

PgNumeric<{
    tableName: "orders";
    name: "total_value";
    data: string;
    driverParam: string;
    notNull: false;
    hasDefault: false;
}>
PgNumeric<{
    tableName: "orders";
    name: "total_value";
    data: string;
    driverParam: string;
    notNull: false;
    hasDefault: false;
}>


but when I do a query such as

await db
        .insert(order)
        .values({
          ...input,
        })
        .returning();
await db
        .insert(order)
        .values({
          ...input,
        })
        .returning();


The result is inferred as
string | null
string | null
for this column rather than
number | null
number | null
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Numeric type returns number instead of string as defined in TypeScript
Drizzle TeamDTDrizzle Team / help
2y ago
Postgres 'with' returns null with basic setup?
Drizzle TeamDTDrizzle Team / help
3y ago
Querying from information schema postgres
Drizzle TeamDTDrizzle Team / help
13mo ago
select with sql<number> returns string
Drizzle TeamDTDrizzle Team / help
8mo ago