Skip to content

"Do not know how to serialize a BigInt" when inserting numbers #21

@gskril

Description

@gskril

I have the example SQL schema from Cloudflare's docs:

CREATE TABLE IF NOT EXISTS Customers (CustomerId INTEGER PRIMARY KEY, CompanyName TEXT, ContactName TEXT);

INSERT INTO Customers (CustomerID, CompanyName, ContactName) VALUES (1, 'Alfreds Futterkiste', 'Maria Anders'), (4, 'Around the Horn', 'Thomas Hardy'), (11, 'Bs Beverages', 'Victoria Ashworth'), (13, 'Bs Beverages', 'Random Name');

And this Kysely code (removed some Worker boiler plate code for simplicity):

import { Kysely } from 'kysely';
import { D1Dialect } from 'kysely-d1';
import { Env } from '../env';

interface Customers {
  CustomerID: number;
  CompanyName: string;
  ContactName: string;
}

interface Database {
  Customers: Customers;
}

const db = new Kysely<Database>({ dialect: new D1Dialect({ database: env.DB }) });

await db
  .insertInto('Customers')
  .values({
    CustomerID: 7,
    ContactName: 'test',
    CompanyName: 'test',
}).execute();

When the Worker runs, it successfully creates a row in the table but throws the following error:

Do not know how to serialize a BigInt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions