Skip to content

Commit 6476cb4

Browse files
author
Oscar Franco
authored
Merge pull request #17 from vinnybad/main
Use `double` over `int32` for representing numbers when retrieving data from sqlite
2 parents e736497 + da346d8 commit 6476cb4

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ If you are using quick-sqlite in your app, please get in touch or open a PR with
3535
- If you want to run the example project on android, you will have to change the paths on the android/CMakeLists.txt file, they are already there, just uncomment them.
3636
- This library supports SQLite BLOBs which are mapped to JS ArrayBuffers, check out the sample project on how to use it
3737
- Starting with version 2.0.0 the library no longer throws errors when an invalid statement is passed, but rather returns an object with a `status` enum property, where 0 signals a succesful execution and `1` an incorrect execution (this is to keep typeorm from exploding when an incorrect query is executed)
38+
- This library cannot retrieve integers larger than 53 bits because it's not possible to represent such numbers in JavaScript. [Read here](https://github.com/ospfranco/react-native-quick-sqlite/issues/16#issuecomment-1018412991) for more information.
3839

3940
## Use TypeORM
4041

cpp/sequel.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,14 @@ SequelResult sequel_execute(jsi::Runtime &rt, string const dbName, string const
306306

307307
case SQLITE_INTEGER:
308308
{
309-
int column_value = sqlite3_column_int(statement, i);
309+
/**
310+
* It's not possible to send a int64_t in a jsi::Value because JS cannot represent the whole number range.
311+
* Instead, we're sending a double, which can represent all integers up to 53 bits long, which is more
312+
* than what was there before (a 32-bit int).
313+
*
314+
* See https://github.com/ospfranco/react-native-quick-sqlite/issues/16 for more context.
315+
*/
316+
double column_value = sqlite3_column_double(statement, i);
310317
entry.setProperty(rt, column_name.c_str(), jsi::Value(column_value));
311318
break;
312319
}

0 commit comments

Comments
 (0)