Skip to content

Mutating operations are const methods on Database (const-correctness lie) #26

@jkalias

Description

@jkalias

Problem

Database::Instance() returns const Database&, yet the mutating operations Save, SaveAutoIncrement, Update, and Delete (include/database.h) are declared const and are callable on that const reference even though they modify the underlying database.

Impact

Mechanically harmless (the SQLite handle is mutated through a sqlite3* member, which const doesn't protect), but the API misrepresents intent: a const reference appears read-only while it can mutate persistent state. This is a design/maintainability smell and can mislead callers reasoning about thread-safety and aliasing.

Suggested direction

Either make the mutators non-const and have Instance() return a non-const reference for write access (possibly a separate const accessor for read-only use), or, if the const-singleton pattern is intentional, document the rationale explicitly.

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