Cannot read properties of undefined (reading 'name')

I have a schema: roles,
export const roles = pgTable('roles', {
  id: uuid('id').defaultRandom().notNull().primaryKey(),
  precedence: integer('precedence').notNull().default(1),
  name: text('name').notNull().unique(),
  notification: notificationEnum('notification').notNull().default('none'),
  notificationScope: notificationScopeEnum('notificationScope').notNull().default('self'),
  invite: inviteEnum('invite').notNull().default('none'),
  role: roleEnum('role').notNull().default('none'),
  quickLink: quickLinkEnum('quickLink').notNull().default('none'),
  course: courseEnum('course').notNull().default('none'),
  profile: profile('profile').notNull().default('write'),
  profileScope: profileScope('profileScope').notNull().default('self'),
  batch: batch('batch').notNull().default('none'),
  marks: marksEnum('marks_enum').notNull().default('read'),
  marksScope: marksScope('marksScope').notNull().default('self'),
  registrations: registrationEnum('registrations_enum').notNull().default('read'),
  registrationScope: registrationScope('registrationScope').notNull().default('self')
})

I wrote code to update roles:
    const updatedRole = await db
      .update(roles)
      .set(role)
      .where(eq(roles.id, role.id as string))
      .returning()

    console.log('updatedRole:', updatedRole[0])

When i try updating a role i get the following error:

TypeError: Cannot read properties of undefined (reading 'name')
    at -------\node_modules\drizzle-orm\index-1899b9ae.cjs:2084:51
    at Array.flatMap (<anonymous>)
    at PgDialect.buildUpdateSet (------\node_modules\drizzle-orm\index-1899b9ae.cjs:2082:14)
    ...

I opened up the file and noticed that 'buildUpdateSet' is unable to get one of the columns
The file is from drizzle-orm so i might be a bug?
Was this page helpful?