© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•14mo ago•
2 replies
Kedalen

inferInsert returns unexpected type?

Hello!
I'm probably just dumb but shouldn't a schema like this

export const subscriptions = pgTable('subscriptions', {
  id: uuid('id').defaultRandom().primaryKey(),
  userId: text('user_id')
    .references(() => user.id)
    .notNull(),
  stripeCustomerId: text('stripe_customer_id').notNull().unique(),
  productId: integer('product_id').references(() => products.id),
  stripeSubscriptionId: text('stripe_subscription_id').notNull(),
  status: subscriptionStatus('status').default('active'),
  currentPeriodStart: timestamp('current_period_start').notNull(),
  currentPeriodEnd: timestamp('current_period_end').notNull(),
});
export const subscriptions = pgTable('subscriptions', {
  id: uuid('id').defaultRandom().primaryKey(),
  userId: text('user_id')
    .references(() => user.id)
    .notNull(),
  stripeCustomerId: text('stripe_customer_id').notNull().unique(),
  productId: integer('product_id').references(() => products.id),
  stripeSubscriptionId: text('stripe_subscription_id').notNull(),
  status: subscriptionStatus('status').default('active'),
  currentPeriodStart: timestamp('current_period_start').notNull(),
  currentPeriodEnd: timestamp('current_period_end').notNull(),
});

be infered like using
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];
export type SubscriptionInsert = (typeof subscriptions)['$inferInsert'];

to
export type ExpectedType = {
  userId: string;
  stripeCustomerId: string;
  productId?: number;
  stripeSubscriptionId: string;
  status?: string; //Enum values string for simplicity
  currentPeriodStart: Date;
  currentPeriodEnd: Date;
};
export type ExpectedType = {
  userId: string;
  stripeCustomerId: string;
  productId?: number;
  stripeSubscriptionId: string;
  status?: string; //Enum values string for simplicity
  currentPeriodStart: Date;
  currentPeriodEnd: Date;
};

instead of
type ActualType = {
    userId: string;
    stripeCustomerId: string;
    stripeSubscriptionId: string;
    currentPeriodStart: Date;
    currentPeriodEnd: Date;
    //status and product missing
}
type ActualType = {
    userId: string;
    stripeCustomerId: string;
    stripeSubscriptionId: string;
    currentPeriodStart: Date;
    currentPeriodEnd: Date;
    //status and product missing
}

Am I doing something wrong here?

Thanks
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

customBinary type returns error on insert
Drizzle TeamDTDrizzle Team / help
3y ago
Custom `Select` object returns type `any`
Drizzle TeamDTDrizzle Team / help
3y ago
Type Error when Generating Typebox
Drizzle TeamDTDrizzle Team / help
10mo ago