Repository navigation
feat(orm): add model metadata contract - #96
Merged
Merged
Conversation
Add the C++11 nullable value type, ORM type mapping, model traits macros, column metadata and validate_model<T>() for the 1.12.0 single-table ORM. The layer is header-only except for the status-name helper and reuses uvcpp_db_value; it does not generate SQL or touch the db client. Gate the module behind UVCPP_BUILD_ORM, force it off when DB is disabled, and exclude orm tests when the module is off so an untested configuration is absent rather than green.
The ORM build option and module hooks necessarily insert lines in the root CMakeLists. Update every CMakeLists.txt line citation that moved and refresh the line-reference lock after checking the new targets resolve to the same blocks.
This was referenced Nov 27, 2026
Owner
Author
|
Local review before merge: ORM model tests 192/192, DB SQLite still passes, ORM=OFF has no ORM target, C++11 pedantic build, installed headers compile a standalone consumer, check_docs and check_doc_lines pass. GitHub Actions is still queued on shared runners; the only previous failure was the wsdl install-deps job, unrelated to this diff. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #89. Parent: #88. Milestone: 1.12.0.
What changed
Adds the ORM model contract and metadata layer:
uvcpp::nullable<T>— explicit SQL NULL vs. a present zero-length string; no exceptions.uvcpp::uvcpp_orm_type— exact C++ type mapping for bool, signed/unsigned 8/16/32/64-bit integers, float, double,std::string,std::vector<uint8_t>andnullable<T>.uvcpp::uvcpp_orm_column/model_traits<T>/validate_model<T>()— table name, column name/type/offset/size/flags, primary key lookup, duplicate/flag/auto-increment validation.UVCPP_ORM_MODEL/UVCPP_ORM_FIELD/UVCPP_ORM_MODEL_ENDdeclaration macros.UVCPP_BUILD_ORM(default OFF, requiresUVCPP_ENABLE_DB=ON); forced OFF with a configure warning when DB is off.tests/functional/orm_model_func.cppand CMake discovery filtering: with ORM off the test is absent, not green.include/orm/headers when ORM is enabled, and registersUVCPP_ORM_ENABLEin the config contract.This layer does not generate SQL, execute CRUD, open connections, or change any DB/C ABI behavior. SQL construction, CRUD, transactions/async and benchmarks follow in #90–#95.
Verification
Environment: Linux x86_64, g++ 13.3.0, CMake Release, SQLite 3.45.1.
C++11 compile:
ORM off:
Also verified:
UVCPP_BUILD_ORM=ONwithUVCPP_ENABLE_DB=OFFis forced OFF with the CMake warning above.test_orm_model_funccovers nullable empty/value/empty-string/move/reset/value_or, every supported type mapping, macro-generated offsets/order/flags, and all validation failure paths.Unverified
offsetofon aggregates containingstd::stringis conditionally supported in C++11; it works on g++ 13.3, and the limitation is documented in the header. MSVC needs confirmation in the CI matrix ([ORM] 跨后端测试与 CI #93).Review focus
nullable<T>,model_traits<T>and the three macros before dependent SQL/CRUD work starts.UVCPP_BUILD_ORMdefault OFF is the right release default (turn-on belongs to [ORM] 文档、示例与发布门禁 #94 packaging/release).