Skip to content

SyntaxError: Failed to parse String to BigInt #423

@mwillbanks

Description

@mwillbanks

Reproduction: Attempt to update any model with a BigInt primary key:

model Account {
  accountId             BigInt          @id @default(autoincrement()) @map("account_id")
  email                 String


  @@map("account")
}
zenstack.Account.update({
  data: {
    email: 'foo@bar.org',
  },
  where: {
    accountId: 1n
  }
});

Error:

SyntaxError: Failed to parse String to BigInt
      at addBigIntValidation (/node_modules/@zenstackhq/orm/dist/index.js:3701:23)
      at <anonymous> (/node_modules/@zenstackhq/orm/dist/index.js:4095:40)
      at with (/node_modules/ts-pattern/dist/index.js:1:7550)
      at makePrimitiveSchema (/node_modules/@zenstackhq/orm/dist/index.js:4093:408)
      at <anonymous> (/node_modules/@zenstackhq/orm/dist/index.js:4826:32)
      at forEach (1:11)
      at makeUpdateDataSchema (/node_modules/@zenstackhq/orm/dist/index.js:4799:34)
      at makeUpdateSchema (/node_modules/@zenstackhq/orm/dist/index.js:4756:18)
      at validate (/node_modules/@zenstackhq/orm/dist/index.js:4045:16)
      at <anonymous> (/node_modules/@zenstackhq/orm/dist/index.js:3476:87)
      at with (/node_modules/ts-pattern/dist/index.js:1:7550)
      at handle (/node_modules/@zenstackhq/orm/dist/index.js:3476:31)
      at handle (/node_modules/@zenstackhq/orm/dist/index.js:3474:16)
      at <anonymous> (/node_modules/@zenstackhq/orm/dist/index.js:6866:34)
      at proceed (/node_modules/@zenstackhq/orm/dist/index.js:6864:51)
      at <anonymous> (/node_modules/@zenstackhq/orm/dist/index.js:6863:41)
      at cb (/node_modules/@zenstackhq/orm/dist/index.js:6467:41)
      at then (/node_modules/@zenstackhq/orm/dist/index.js:6474:14)

This appears to be due to what is being passed to the addBigIntValidation function:

{
  attr: {
    name: "@map",
    args: [
      [Object ...]
    ],
  },
  val: "account_id",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions