© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
Valentin W

Numeric type returns number instead of string as defined in TypeScript

Hello, I'm trying Drizzle ORM with PostgreSQL and TypeScript. I've noticed a discrepancy between the TypeScript definitions and the actual runtime behavior for numeric fields.

Schema definition:
export const bankrolls = pgTable('bankrolls', {
  id: uuid('id').primaryKey(),
  name: varchar('name'),
  startingCapital: numeric('starting_capital', { precision: 8, scale: 2 }),
});
export const bankrolls = pgTable('bankrolls', {
  id: uuid('id').primaryKey(),
  name: varchar('name'),
  startingCapital: numeric('starting_capital', { precision: 8, scale: 2 }),
});


The request
async all(userId: string): Promise<BankrollsViewModel[]> {
  const result = await this.sqlConnection
    .select()
    .from(bankrolls)
    .where(eq(bankrolls.userId, userId));
  return result;
}
async all(userId: string): Promise<BankrollsViewModel[]> {
  const result = await this.sqlConnection
    .select()
    .from(bankrolls)
    .where(eq(bankrolls.userId, userId));
  return result;
}


The type of result is inferred as:
{
  id: string;
  name: string;
  startingCapital: string; // Note: string
}[]
{
  id: string;
  name: string;
  startingCapital: string; // Note: string
}[]


However, when I log the actual value of startingCapital, it's a number:
console.log(typeof result[0].startingCapital); // Outputs: "number"
console.log(typeof result[0].startingCapital); // Outputs: "number"


Expected behavior: startingCapital should be a string to match the TypeScript definition. Actual behavior: startingCapital is a number.
My version are :
"drizzle-orm": "^0.33.0",
"drizzle-kit": "^0.24.2"

I just want the type and runtime value to match, regardless of whether it's a string or a number
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 as number instead of a string
Drizzle TeamDTDrizzle Team / help
13mo ago
latitude and longitude are string type but were defined as numeric
Drizzle TeamDTDrizzle Team / help
2y ago
numeric returns string when querying with Postgres
Drizzle TeamDTDrizzle Team / help
3y ago
select with sql<number> returns string
Drizzle TeamDTDrizzle Team / help
8mo ago