Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pick][fix] return empty results when provided object lookup keys are empty… #19716

Open
wants to merge 1 commit into
base: releases/sui-v1.34.0-release
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/sui-graphql-rpc/src/types/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,10 @@ impl Loader<HistoricalKey> for Db {
async fn load(&self, keys: &[HistoricalKey]) -> Result<HashMap<HistoricalKey, Object>, Error> {
use objects_version::dsl as v;

if keys.is_empty() {
return Ok(HashMap::new());
}

let id_versions: BTreeSet<_> = keys
.iter()
.map(|key| (key.id.into_vec(), key.version as i64))
Expand All @@ -1280,6 +1284,9 @@ impl Loader<HistoricalKey> for Db {
.into_boxed();

for (id, version) in id_versions.iter().cloned() {
// TODO: consider using something other than `or_filter` to avoid returning
// all results when `id_versions` is empty. It is mitigated today by the
// early return above.
query = query
.or_filter(v::object_id.eq(id).and(v::object_version.eq(version)));
}
Expand Down Expand Up @@ -1538,6 +1545,10 @@ impl Loader<PointLookupKey> for Db {
) -> Result<HashMap<PointLookupKey, Option<Vec<u8>>>, Error> {
use full_objects_history::dsl as f;

if keys.is_empty() {
return Ok(HashMap::new());
}

let id_versions: BTreeSet<_> = keys
.iter()
.map(|key| (key.id.into_vec(), key.version as i64))
Expand All @@ -1551,6 +1562,9 @@ impl Loader<PointLookupKey> for Db {
.into_boxed();

for (id, version) in id_versions.iter() {
// TODO: consider using something other than `or_filter` to avoid returning
// all results when `id_versions` is empty. It is mitigated today by the
// early return above.
query = query.or_filter(
f::object_id
.eq(id.clone())
Expand Down
Loading