修复in的bug

Signed-off-by: MengYao <mengyao17@huawei.com>
This commit is contained in:
MengYao 2024-08-05 20:49:31 +08:00
parent d7cc9263ed
commit b25aa1c571
5 changed files with 17 additions and 3 deletions

View File

@ -673,6 +673,9 @@ napi_value RdbPredicatesProxy::In(napi_env env, napi_callback_info info)
auto predicatesProxy = ParseFieldAndValueArray(env, info, thiz, field, values, "ValueType");
RDB_CHECK_RETURN_NULLPTR(predicatesProxy != nullptr && predicatesProxy->predicates_ != nullptr,
"RdbPredicatesProxy predicatesProxy or predicates_ is nullptr");
if (values.empty()) {
return thiz;
}
predicatesProxy->predicates_->In(field, values);
return thiz;
}
@ -685,6 +688,9 @@ napi_value RdbPredicatesProxy::NotIn(napi_env env, napi_callback_info info)
auto predicatesProxy = ParseFieldAndValueArray(env, info, thiz, field, values, "ValueType");
RDB_CHECK_RETURN_NULLPTR(predicatesProxy != nullptr && predicatesProxy->predicates_ != nullptr,
"RdbPredicatesProxy predicatesProxy or predicates_ is nullptr");
if (values.empty()) {
return thiz;
}
predicatesProxy->predicates_->NotIn(field, values);
return thiz;
}

View File

@ -652,6 +652,9 @@ napi_value RdbPredicatesProxy::In(napi_env env, napi_callback_info info)
std::vector<ValueObject> values;
auto predicatesProxy = ParseFieldAndValueArray(env, info, thiz, field, values, "ValueType");
CHECK_RETURN_NULL(predicatesProxy && predicatesProxy->GetInstance());
if (values.empty()) {
return thiz;
}
predicatesProxy->GetInstance()->In(field, values);
return thiz;
}
@ -663,6 +666,9 @@ napi_value RdbPredicatesProxy::NotIn(napi_env env, napi_callback_info info)
std::vector<ValueObject> values;
auto predicatesProxy = ParseFieldAndValueArray(env, info, thiz, field, values, "ValueType");
CHECK_RETURN_NULL(predicatesProxy && predicatesProxy->GetInstance());
if (values.empty()) {
return thiz;
}
predicatesProxy->GetInstance()->NotIn(field, values);
return thiz;
}

View File

@ -120,6 +120,7 @@ int AbsSharedResultSet::GoToRow(int position)
if (position >= rowCnt || position < 0) {
rowPos_ = (position >= rowCnt && rowCnt != 0) ? rowCnt : rowPos_;
LOG_DEBUG("position[%{public}d] rowCnt[%{public}d] rowPos[%{public}d]!", position, rowCnt, rowPos_);
return E_ROW_OUT_RANGE;
}

View File

@ -213,8 +213,9 @@ int SqliteSharedResultSet::FillBlock(int requiredPos)
return errCode;
}
blockCapacity_ = block->GetRowNum();
if ((block->GetStartPos() == block->GetLastPos() && rowCount_ != block->GetStartPos())
|| (requiredPos < block->GetStartPos() || block->GetLastPos() <= requiredPos)) {
if ((block->GetStartPos() == block->GetLastPos() && (uint32_t)rowCount_ != block->GetStartPos())
|| ((uint32_t)requiredPos < block->GetStartPos() || block->GetLastPos() <= (uint32_t)requiredPos)
|| block->GetStartPos() > 0) {
LOG_WARN("blockRowNum=%{public}d, requiredPos= %{public}d, startPos_= %{public}" PRIu32
", lastPos_= %{public}" PRIu32 ", blockPos_= %{public}" PRIu32 ".",
rowCount_, requiredPos, block->GetStartPos(), block->GetLastPos(), block->GetBlockPos());

View File

@ -2464,7 +2464,7 @@ describe('rdbPredicatesTest', function () {
let predicates = new dataRdb.RdbPredicates("AllDataType");
predicates.in("doubleValue", values);
let result = await rdbStore.query(predicates);
expect(0).assertEqual(result.rowCount);
expect(3).assertEqual(result.rowCount);
result.close()
done();
console.log(TAG + "************* testIn0005 end *************");