K
Kyselyโ€ข2y 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โ€ข2y ago
Hey ๐Ÿ‘‹๐Ÿป Number of rows in a single table can exceed JavaScript integer safe number range.
Solution
koskimas
koskimasโ€ข2y 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
oof2win2OPโ€ข2y 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โ€ข2y ago
No, the ID can exceed the safe integer range
oof2win2
oof2win2OPโ€ข2y ago
hmm i see the dillema
koskimas
koskimasโ€ข2y 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
oof2win2OPโ€ข2y 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โ€ข2y ago
Well I'm pretty sure you didn't find a bug in typescript.
oof2win2
oof2win2OPโ€ข2y ago
it was found before
oof2win2
oof2win2OPโ€ข2y 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
oof2win2OPโ€ข2y ago
that's what i meant, not amazing wording from my side
koskimas
koskimasโ€ข2y ago
You could compare it to a zero bigint literalresult.numUpdateRows !== 0n?
oof2win2
oof2win2OPโ€ข2y ago
yeah thats what i did in the end
Igal
Igalโ€ข2y 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โ€ข2y ago
Damn that was a great show! I hated the ending though
Want results from more Discord servers?
Add your server