jawj / zapatos

Zero-abstraction Postgres for TypeScript: a non-ORM database library
https://jawj.github.io/zapatos/
Other
1.3k stars 46 forks source link

unable to insert bigint to bigint column #154

Closed jcoveney-anchorzero closed 1 year ago

jcoveney-anchorzero commented 1 year ago

hello! if this is supported in some way, I apologize and would appreciate being led in the right direction. zapatos version 6.1.4

we are using postgres and have a table something like

model Test {
    test_id BigInt @id
}

(we use prisma for the schema definition, and have been using prisma but are slowly moving to an all zapatos world)

const test_id = BigInt(1);
await zapatosDb.insert('test', { test_id }).run(poolTx);

this throws an error. I was able to get it compiling at least using the following:

const test_id = BigInt(1);
await zapatosDb.insert('test', {
    test_id: zapatosDb.sql`${zapatosDb.param(test_id)}`,
}).run(poolTx);

but I'm not quite sure if that works yet (this is coming up in a more complicated app so getting to where I can test if this works or not will take a little time). I thought I'd ask about the most natural way to deal with bigints and zapatos. I tried doing a string directly, and that didn't work. it seems to be expecting a number or some number-like object, which seems wrong?

jcoveney-anchorzero commented 1 year ago

actually, it looks like bigint values are also getting returned as number when I query the database, which seems like a more serious limitation

jawj commented 1 year ago

Thanks for posting. I'm working on fixing this.

jcoveney-anchorzero commented 1 year ago

very exciting! no rush of course as I know you have a lot on your plate, but I'm very excited to see how you tackle it! we've been spending a lot of time thinking about this part of zapatos as of late

jawj commented 1 year ago

Hi @jcoveney-anchorzero. There's progress on this! Please see https://github.com/jawj/zapatos/issues/95#issuecomment-1816858711

jawj commented 1 year ago

This should be fixed in 6.3, just released: https://jawj.github.io/zapatos/#custom-json-parsing-for-bigint-and-numeric