Perfect-SQLite icon indicating copy to clipboard operation
Perfect-SQLite copied to clipboard

lastInsertRowId is truncated to Int

Open zmeyc opened this issue 9 years ago • 2 comments

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

zmeyc avatar Jun 27 '16 01:06 zmeyc

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!

iamjono avatar Jun 27 '16 15:06 iamjono

@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.

zmeyc avatar Jun 27 '16 15:06 zmeyc