Skip to content
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

lastInsertRowId is truncated to Int #1

Open
zmeyc opened this issue Jun 27, 2016 · 2 comments
Open

lastInsertRowId is truncated to Int #1

zmeyc opened this issue Jun 27, 2016 · 2 comments
Assignees

Comments

@zmeyc
Copy link

zmeyc commented Jun 27, 2016

In Perfect-SQLite lastInsertRowId is truncated to Int. In SQLite it's int64:
sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);

@iamjono
Copy link
Member

iamjono commented Jun 27, 2016

Thanks @zmeyc - At a cursory look, lastInsertRowID() is returning an Int type, which on 32-bit systems is the same size as Int32, on 64-bit systems is the same size as Int64. So, something else is at play here, and we'll keep looking.
Can you confirm what OS you observed this on?
Thanks!

@zmeyc
Copy link
Author

zmeyc commented Jun 27, 2016

@iamjono Then this is not much of a problem, at least on OS X. But I think it would be more correct to explicitly return Int64 on any architecture, as rowIds in sqlite are always 64-bit signed integers.

For example, Telegram userIds (53 bit values) in my app are stored in INTEGER PRIMARY KEY column which becomes rowid. If I'll use last_insert_rowid, they will be truncated on 32 bit systems.

@iamjono iamjono self-assigned this Jun 27, 2016
kjessup added a commit that referenced this issue Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants