Repository navigation
feat(orm): use transactions and the existing async facades - #101
Merged
Merged
Conversation
Factor the repository through client/tx/pool executors, add transaction overloads so ORM statements share the tx connection and preserve its first-error semantics, and add callback-style async CRUD on uvcpp_db_pool with submit-failure versus execution-failure separation. Add SQLite transaction, callback-count, pool max=1 and borrow-timeout tests (183 checks); PostgreSQL native async remains unverified without a server.
Owner
Author
|
Local review before merge: transaction and async tests 183/183 on SQLite, ORM model 192/192, SQL 295/295, CRUD 117/117, DB SQLite 196 passed / 0 failed / 1 N/A. Callback counts, submission failures, pool max=1 and borrow timeout were exercised. PostgreSQL native async and other servers remain explicitly unverified; shared-runner CI is queued. |
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 #92. Parent: #88.
What changed
Transaction reuse
src/orm/uvcpp_orm_repository.hnow runs through one of three executors:uvcpp_db_client&— the existing synchronous path from [ORM] 结果映射与 CRUD #91;uvcpp_db_tx&— every ORM statement goes through the transaction's own gate and connection; the ORM never callsbegin()/commit()/rollback()itself. The first failure remains visible throughtx.status()/tx.error();uvcpp_db_pool&— synchronous borrow/release for callers not on the event loop.The same overloads cover
find_by_pk,find_all,insert,update,removeandcount. Primary-key update/remove and insert/read-mapping semantics are unchanged.Async facade
src/orm/uvcpp_orm_async.hadds callback-style:find_by_pk_async,find_all_async,insert_async,update_async,remove_async.It reuses
uvcpp_db_pool's existing async paths; no new threads, pool or connection ownership. Submission failure returns a negative libuv code and does not call the callback; execution/mapping failure calls it exactly once withDB_ERRORand the underlying status name.insert_asyncuses the existing pool transaction path so it can returnlast_insert_idwithout adding a second async primitive.Tests
tests/functional/orm_tx_async_func.cpp— 183 checks, real SQLite:max=1mixed concurrency and borrow timeout;Verification
C++11
-pedantic-errorscompilation was exercised through the build. With ORM=OFF theorm_*targets are absent and the DB SQLite test remains.Unverified / limits
find_all_asyncdeliberately has nototalparameter: that would require a second SQL round trip while promising one callback. Use a follow-up count query or the synchronous overload when a total is needed.