Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static VersionedAspect getAspectFromLocalContext(DataFetchingEnvironment
Object localContext = environment.getLocalContext();
// if we have context & the version is 0, we should try to retrieve it from the fetched entity
// otherwise, we should just fetch the entity from the aspect resource
if (localContext == null && version == 0 || version == null) {
if (localContext != null && version == 0 || version == null) {
if (localContext instanceof Map) {
// de-register the prefetched aspect from local context. Since aspects will only
// ever be first-class properties of an entity type, local context will always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Map<Urn, List<RecordTemplate>> getLatestAspects(@Nonnull final Set<Urn> u
@Nullable
public RecordTemplate getAspect(@Nonnull final Urn urn, @Nonnull final String aspectName, @Nonnull long version) {
if (version < 0) {
version = _entityDao.getMaxVersion(urn.toString(), aspectName) - version + 1;
version = _entityDao.getMaxVersion(urn.toString(), aspectName) + version + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment about why this is the right math?

}
final EbeanAspectV2.PrimaryKey primaryKey = new EbeanAspectV2.PrimaryKey(urn.toString(), aspectName, version);
final Optional<EbeanAspectV2> maybeAspect = Optional.ofNullable(_entityDao.getAspect(primaryKey));
Expand Down