-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get wrong values from the database when using node-sqlite #17
Comments
Hi Sam, It seems your 'seconds' values are actually in milliseconds. I have committed a "fix" for this issue in changeset 20ed195db941163848313f74755d77ec0c0f6084. The cause was the node-sqlite code calling sqlite3_column_int rather than sqlite3_column_int64. Sadly there is no support for 64bit integers in Node JS (that I know of) so the numbers are represented as doubles ... so you only get 52 bits of precision. We could consider using a BigNum library for these values... |
Sam, what you're running into is an unfortunate cross-section of limitations present both in JavaSript and SQLite. SQLite's type affinity is forcing the driver to interpret the value in your select as an INTEGER column type. As Steven mentioned, JavaScript doesn't support very large integers. Because SQLite stores everything under the hood as strings, you could simply request your data as TEXT using CAST:
|
I have a table column where I store large numbers (seconds since 1970).
The bigints are stored correctly (I checked it on the sqlite console) but with the sqlite driver I get negative(!) values. What's wrong here?
sqlite3 console:
sqlite> SELECT date FROM seen WHERE user='root' COLLATE NOCASE;
1296333940003
node-sqlite:
{ date: -746187876 }
I also tried "BIGINT UNSIGNED" with the same (wrong) result.
The text was updated successfully, but these errors were encountered: