K
Kyselyโ€ข13mo ago
oof2win2

Why is numUpdatedRows a BigInt?

Hi. I'd just like to ask as to why the number of updated rows in Kysely is a BigInt, as for all other ORMs that I've seen, it's just a normal number. Was there any reason for this decision?
Solution:
In reality it can't. That SSD would use up all the atoms in the universe ๐Ÿ˜„ It's more for consistency. The inserted row's ID in the InsertObject needs to be a bigint. Therefore all the others are too....
Jump to solution
15 Replies
Igal
Igalโ€ข13mo ago
Hey ๐Ÿ‘‹๐Ÿป Number of rows in a single table can exceed JavaScript integer safe number range.
Solution
koskimas
koskimasโ€ข13mo ago
In reality it can't. That SSD would use up all the atoms in the universe ๐Ÿ˜„ It's more for consistency. The inserted row's ID in the InsertObject needs to be a bigint. Therefore all the others are too.
oof2win2
oof2win2โ€ข13mo ago
so would it make sense to change both of them to number instead? i mean the updated rows would make more sense being an int
koskimas
koskimasโ€ข13mo ago
No, the ID can exceed the safe integer range
oof2win2
oof2win2โ€ข13mo ago
hmm i see the dillema
koskimas
koskimasโ€ข13mo ago
Easily. The ID is not always automatically generated. It might be random 64bit integer for example. Or you could start the generator from some huge number. Or you could reset it to a huge number. You can just do this though Number(result.numUpdatedRows)
oof2win2
oof2win2โ€ข13mo ago
fair enough i was just trying to check if it was more than zero which should be true, found another bug with TS though lol anyways, thanks ๐Ÿ‘
koskimas
koskimasโ€ข13mo ago
Well I'm pretty sure you didn't find a bug in typescript.
oof2win2
oof2win2โ€ข13mo ago
it was found before
oof2win2
oof2win2โ€ข13mo ago
GitHub
'bigint' is not comparable to 'number' with loose equality ยท Issue ...
TypeScript Version: 3.3.3 Search Terms: bigin == number not comparable loose equality Code 1n == 1 error: This condition will always return 'false' since the types 'bigint' and '...
oof2win2
oof2win2โ€ข13mo ago
that's what i meant, not amazing wording from my side
koskimas
koskimasโ€ข13mo ago
You could compare it to a zero bigint literalresult.numUpdateRows !== 0n?
oof2win2
oof2win2โ€ข13mo ago
yeah thats what i did in the end
Igal
Igalโ€ข13mo ago
In reality it can't. That SSD would use up all the atoms in the universe ๐Ÿ˜„
Ever heard about middle-out compression? ๐Ÿคฃ
koskimas
koskimasโ€ข13mo ago
Damn that was a great show! I hated the ending though
Want results from more Discord servers?
Add your server
More Posts