diff --git a/extensions/common/store/sql/edr-index-sql/src/main/java/org/eclipse/edc/edr/store/index/sql/schema/postgres/EndpointDataReferenceEntryMapping.java b/extensions/common/store/sql/edr-index-sql/src/main/java/org/eclipse/edc/edr/store/index/sql/schema/postgres/EndpointDataReferenceEntryMapping.java index 48087c4a4ed..a2dfc5aa230 100644 --- a/extensions/common/store/sql/edr-index-sql/src/main/java/org/eclipse/edc/edr/store/index/sql/schema/postgres/EndpointDataReferenceEntryMapping.java +++ b/extensions/common/store/sql/edr-index-sql/src/main/java/org/eclipse/edc/edr/store/index/sql/schema/postgres/EndpointDataReferenceEntryMapping.java @@ -29,5 +29,6 @@ public EndpointDataReferenceEntryMapping(EndpointDataReferenceEntryStatements st add("transferProcessId", statements.getTransferProcessIdColumn()); add("providerId", statements.getProviderIdColumn()); add("contractNegotiationId", statements.getContractNegotiationIdColumn()); + add("createdAt", statements.getCreatedAtColumn()); } } diff --git a/spi/common/edr-store-spi/src/testFixtures/java/org/eclipse/edc/edr/spi/store/EndpointDataReferenceEntryIndexTestBase.java b/spi/common/edr-store-spi/src/testFixtures/java/org/eclipse/edc/edr/spi/store/EndpointDataReferenceEntryIndexTestBase.java index 057d063d2c4..0977e578bf1 100644 --- a/spi/common/edr-store-spi/src/testFixtures/java/org/eclipse/edc/edr/spi/store/EndpointDataReferenceEntryIndexTestBase.java +++ b/spi/common/edr-store-spi/src/testFixtures/java/org/eclipse/edc/edr/spi/store/EndpointDataReferenceEntryIndexTestBase.java @@ -18,6 +18,7 @@ import org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry; import org.eclipse.edc.spi.query.Criterion; import org.eclipse.edc.spi.query.QuerySpec; +import org.eclipse.edc.spi.query.SortOrder; import org.eclipse.edc.spi.result.StoreFailure; import org.eclipse.edc.spi.result.StoreResult; import org.junit.jupiter.api.Test; @@ -27,6 +28,7 @@ import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsSource; +import java.util.Comparator; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -119,6 +121,20 @@ void query_withQuerySpec(String field, Function TestFunctions.edrEntry("assetId" + i, "agreementId" + i, "tpId" + i, "cnId" + i)) + .forEach(entry -> getStore().save(entry)); + + var results = getStore().query(QuerySpec.Builder.newInstance().sortField("createdAt").sortOrder(SortOrder.DESC).build()); + + assertThat(results.succeeded()).isTrue(); + assertThat(results.getContent()) + .isSortedAccordingTo(Comparator.comparing(EndpointDataReferenceEntry::getCreatedAt).reversed()); + + } + @Test void delete_shouldDelete_WhenFound() {