Copilot commented on code in PR #6352: URL: https://github.com/apache/ignite-3/pull/6352#discussion_r2245867471
########## modules/platforms/cpp/tests/client-test/transactions_test.cpp: ########## @@ -434,3 +434,53 @@ TEST_F(transactions_test, record_view_remove_all_exact) { auto values2 = record_view.remove_all(nullptr, {value0}); ASSERT_TRUE(values2.empty()); } + +TEST_F(transactions_test, tx_successful_when_timeout_does_not_exceed) { + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); + + int64_t key = 42; + std::string val = "Lorem ipsum"; + auto tx = m_client.get_transactions().begin(transaction_options {.timeoutMillis = 10'000L, .readOnly = true}); + + record_view.insert(nullptr, get_tuple(key, val)); + Review Comment: The transaction is created as read-only but then used for an insert operation on line 445. This is logically inconsistent as read-only transactions should not perform write operations. ```suggestion record_view.insert(nullptr, get_tuple(key, val)); auto tx = m_client.get_transactions().begin(transaction_options {.timeoutMillis = 10'000L, .readOnly = true}); ``` ########## modules/platforms/cpp/ignite/client/transaction/transactions.h: ########## @@ -45,16 +46,18 @@ class transactions { * * @return A new transaction. */ - IGNITE_API transaction begin() { - return sync<transaction>([this](auto callback) { begin_async(std::move(callback)); }); + IGNITE_API transaction begin(transaction_options tx_opts = {.timeoutMillis = 0, .readOnly = false}) { Review Comment: Default parameter values in function declaration should match the struct's default values. Consider using default-initialized struct: 'transaction_options tx_opts = {}' to avoid duplication and potential inconsistency. ```suggestion IGNITE_API transaction begin(transaction_options tx_opts = {}) { ``` ########## modules/platforms/cpp/tests/client-test/transactions_test.cpp: ########## @@ -434,3 +434,53 @@ TEST_F(transactions_test, record_view_remove_all_exact) { auto values2 = record_view.remove_all(nullptr, {value0}); ASSERT_TRUE(values2.empty()); } + +TEST_F(transactions_test, tx_successful_when_timeout_does_not_exceed) { + auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view(); + + int64_t key = 42; + std::string val = "Lorem ipsum"; + auto tx = m_client.get_transactions().begin(transaction_options {.timeoutMillis = 10'000L, .readOnly = true}); + + record_view.insert(nullptr, get_tuple(key, val)); Review Comment: This insert operation is not using the transaction 'tx' created on line 443. It should be 'record_view.insert(&tx, get_tuple(key, val))' to actually test the transaction timeout functionality. ```suggestion record_view.insert(&tx, get_tuple(key, val)); ``` ########## modules/platforms/cpp/ignite/client/transaction/transactions.h: ########## @@ -45,16 +46,18 @@ class transactions { * * @return A new transaction. */ - IGNITE_API transaction begin() { - return sync<transaction>([this](auto callback) { begin_async(std::move(callback)); }); + IGNITE_API transaction begin(transaction_options tx_opts = {.timeoutMillis = 0, .readOnly = false}) { + return sync<transaction>([this, &tx_opts](auto callback) { begin_async(std::move(callback), tx_opts); }); } /** * Starts a new transaction asynchronously. * * @param callback Callback to be called with a new transaction or error upon completion of asynchronous operation. */ - IGNITE_API void begin_async(ignite_callback<transaction> callback); + IGNITE_API void begin_async( + ignite_callback<transaction> callback, + transaction_options tx_opts = {.timeoutMillis = 0, .readOnly = false}); Review Comment: Default parameter values in function declaration should match the struct's default values. Consider using default-initialized struct: 'transaction_options tx_opts = {}' to avoid duplication and potential inconsistency. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org