cpp-sqlitelib icon indicating copy to clipboard operation
cpp-sqlitelib copied to clipboard

feat: add create_table DSL, struct mapping, and extended type support

Open Kelvin-laai opened this issue 8 months ago • 0 comments

  • Introduced DECLARE_SQLITE_FIELDS macro for declarative mapping of C++ structs to SQLite tables.

    • Enables ORM-style interaction by registering fields and their corresponding column names.
    • Simplifies querying and data binding using typed structs like UserInfo.
  • Implemented fluent db.create_table("table") DSL for defining SQLite schemas in a readable, chainable syntax.

    • Supports field types (INTEGER, TEXT, BLOB, REAL), constraints (NOT NULL, PRIMARY KEY, AUTOINCREMENT), default values, and string size limits.
    • Used to define tables such as "user" and "people" with full schema control.
  • Extended support for standard library numeric and boolean types:

    • Added explicit specializations for bool, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t.
    • Improved value extraction and binding from SQLite statements.
    • Enhanced type safety and range checks when enabled via SQLITELIB_ENABLE_TYPE_CHECKING.
  • Comprehensive test coverage added:

    • Insertion and querying of structured data.
    • Field binding and result iteration.
    • Exception handling for invalid operations and malformed queries.

This change significantly improves the usability, expressiveness, and robustness of the SQLite ORM layer.

Kelvin-laai avatar May 05 '25 02:05 Kelvin-laai