!1722 适配getrow

Merge pull request !1722 from MengYao/master
This commit is contained in:
openharmony_ci 2024-09-25 16:49:12 +00:00 committed by Gitee
commit 0838d14b26
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 18 additions and 6 deletions

View File

@ -133,15 +133,12 @@ napi_value Convert2JSValue(napi_env env, const Asset &value)
template<>
napi_value Convert2JSValue(napi_env env, const RowEntity &rowEntity)
{
std::vector<napi_property_descriptor> descriptors;
napi_value object = nullptr;
NAPI_CALL_RETURN_ERR(napi_create_object(env, &object), object);
auto &values = rowEntity.Get();
for (auto const &[key, value] : values) {
descriptors.emplace_back(DECLARE_JS_PROPERTY(env, key.c_str(), value));
NAPI_CALL_RETURN_ERR(SetNamedProperty(env, object, key.c_str(), value), object);
}
napi_value object = nullptr;
NAPI_CALL_RETURN_ERR(
napi_create_object_with_properties(env, &object, descriptors.size(), descriptors.data()), object);
return object;
}

View File

@ -270,5 +270,20 @@ describe('rdbStoreResultSetGetRowTest', function () {
expect(false).assertEqual(resultSet.goToLastRow());
console.log(TAG + "************* rdbStoreInsertUndefinedValueTest0008 end *************");
})
/**
* @tc.name rdb store resultSet getRow test
* @tc.number rdbStoreResultSetGoToLastRow0009
* @tc.desc resultSet goToFirstRow test
*/
it('rdbStoreResultSetGetRowTest0009', 0, async function () {
console.log(TAG + "************* rdbStoreResultSetGetRowTest0009 start *************");
let querySql = "SELECT 1";
let resultSet = await rdbStore.querySql(querySql);
expect(true).assertEqual(resultSet.goToFirstRow());
let valueBucket_ret = resultSet.getRow();
expect(1).assertEqual(valueBucket_ret["1"]);
console.log(TAG + "************* rdbStoreResultSetGetRowTest0009 end *************");
})
console.log(TAG + "*************Unit Test End*************");
})