Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
gskril opened this issue Aug 9, 2023 · 1 comment
Open

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

gskril opened this issue Aug 9, 2023 · 1 comment

Comments

@gskril
Copy link

gskril commented Aug 9, 2023

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
@aidenwallis
Copy link
Owner

Hmm, not sure how to properly handle this case, thanks for raising. I'll look into it in a little bit. I have a feeling this is more of a Kysely level thing.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants