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

fix: Descendants entities losing database ID from parent (#3142) #3156

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

ldetmer
Copy link
Contributor

@ldetmer ldetmer commented Aug 23, 2024

If you override the default database ID and are using @Descendants annotation the database ID wasn't getting copied over when migrating keys from ancestor to child

@ldetmer ldetmer requested a review from a team as a code owner August 23, 2024 17:34
Copy link

sonarcloud bot commented Aug 23, 2024

@@ -46,6 +46,7 @@ public static Key getKeyWithoutAncestors(Key entityKey) {
Key.newBuilder(entityKey.getProjectId(), entityKey.getKind(), entityKey.getId());
}
ancestorLookupKey.setNamespace(entityKey.getNamespace());
ancestorLookupKey.setDatabaseId(entityKey.getDatabaseId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's too bad the ancestors can't be explicitly cleared in the builder, or we'd be able to use the copy constructors to avoid direct knowledge of all the individual fields.

public static Key getKeyWithoutAncestors(Key entityKey) {
  return Key.newBuilder(entityKey).withoutAncestors().build();
}

@ldetmer ldetmer merged commit 02a1e65 into main Sep 4, 2024
75 of 76 checks passed
@ldetmer ldetmer deleted the bugfix-361035423 branch September 4, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants