Background
GetMaxId (and its backing FetchMaxIdQuery) existed to support the old SaveAutoIncrement implementation, which computed the next id client-side as SELECT MAX(id) + 1.
As of PR #8, SaveAutoIncrement no longer does this — the id is now assigned natively by SQLite (INTEGER PRIMARY KEY AUTOINCREMENT) and read back via sqlite3_last_insert_rowid(). As a result, nothing in the library's internal save path uses GetMaxId anymore.
Current state
GetMaxId remains only as:
- a public templated method
Database::GetMaxId() (include/database.h),
- backed by
FetchMaxIdQuery (include/queries.h, src/queries.cc),
- with a dedicated test (
tests/database_test.cc).
Question / proposal
Decide whether GetMaxId is still worth exposing as public API now that it has no internal users:
- Option A — Remove it. Delete
Database::GetMaxId(), FetchMaxIdQuery, and the associated test. This is a minor breaking API change.
- Option B — Keep it as a standalone convenience query (
SELECT MAX(id) FROM table) for users who want to inspect the current maximum id, and document it as such.
This was deliberately left out of PR #8 (scoped to fixing SaveAutoIncrement) and split out here so the decision can be made independently. It also clears the last remnant of the user-space id scheme described in the "fixed in #8" note of #9 — once SaveAutoIncrement stopped using GetMaxId, this API and its backing FetchMaxIdQuery became the only code still referencing that approach.
Background
GetMaxId(and its backingFetchMaxIdQuery) existed to support the oldSaveAutoIncrementimplementation, which computed the next id client-side asSELECT MAX(id) + 1.As of PR #8,
SaveAutoIncrementno longer does this — the id is now assigned natively by SQLite (INTEGER PRIMARY KEY AUTOINCREMENT) and read back viasqlite3_last_insert_rowid(). As a result, nothing in the library's internal save path usesGetMaxIdanymore.Current state
GetMaxIdremains only as:Database::GetMaxId()(include/database.h),FetchMaxIdQuery(include/queries.h,src/queries.cc),tests/database_test.cc).Question / proposal
Decide whether
GetMaxIdis still worth exposing as public API now that it has no internal users:Database::GetMaxId(),FetchMaxIdQuery, and the associated test. This is a minor breaking API change.SELECT MAX(id) FROM table) for users who want to inspect the current maximum id, and document it as such.This was deliberately left out of PR #8 (scoped to fixing
SaveAutoIncrement) and split out here so the decision can be made independently. It also clears the last remnant of the user-space id scheme described in the "fixed in #8" note of #9 — onceSaveAutoIncrementstopped usingGetMaxId, this API and its backingFetchMaxIdQuerybecame the only code still referencing that approach.