Skip to content

Reconsider/remove the now-unused GetMaxId API #10

@jkalias

Description

@jkalias

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions