mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-05 04:55:50 +01:00
Fix export of queryable stores with multiple parent IDs
This commit is contained in:
2
gradle/changelog/export_with_multiple_parent_ids.yaml
Normal file
2
gradle/changelog/export_with_multiple_parent_ids.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Export with multiple parent IDs
|
||||
@@ -139,8 +139,8 @@ class SQLiteQueryableStore<T> implements QueryableStore<T>, QueryableMaintenance
|
||||
statement -> {
|
||||
List<R> result = new ArrayList<>();
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
String[] allParentIds = new String[parentIdsLength];
|
||||
while (resultSet.next()) {
|
||||
String[] allParentIds = new String[parentIdsLength];
|
||||
for (int i = 0; i < parentIdsLength; i++) {
|
||||
allParentIds[i] = resultSet.getString(i + 1);
|
||||
}
|
||||
|
||||
@@ -915,6 +915,35 @@ class SQLiteQueryableStoreTest {
|
||||
.containsExactlyInAnyOrder("trillian", "dent");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReadAllWithMultipleIds() {
|
||||
StoreTestBuilder testStoreBuilder = new StoreTestBuilder(connectionString, Repository.class.getName(), Group.class.getName());
|
||||
SQLiteQueryableMutableStore<User> store1 = testStoreBuilder.withIds("42", "astronauts");
|
||||
store1.put("trisha", new User("trillian", "Trillian McMillan", "mcmillan@hog.com"));
|
||||
SQLiteQueryableMutableStore<User> store2 = testStoreBuilder.withIds("42", "earthlings");
|
||||
store2.put("dent", new User("dent", "Arthur Dent", "dent@hog.com"));
|
||||
|
||||
QueryableMaintenanceStore<User> store = testStoreBuilder.forMaintenanceWithSubIds("42");
|
||||
|
||||
Collection<QueryableMaintenanceStore.Row<User>> rows = store.readAll();
|
||||
|
||||
Optional<QueryableMaintenanceStore.Row<User>> trisha = rows.stream()
|
||||
.filter(row -> row.getId().equals("trisha"))
|
||||
.findFirst();
|
||||
assertThat(trisha)
|
||||
.get()
|
||||
.extracting(QueryableMaintenanceStore.Row::getParentIds)
|
||||
.isEqualTo(new String[]{"42", "astronauts"});
|
||||
|
||||
Optional<QueryableMaintenanceStore.Row<User>> dent = rows.stream()
|
||||
.filter(row -> row.getId().equals("dent"))
|
||||
.findFirst();
|
||||
assertThat(dent)
|
||||
.get()
|
||||
.extracting(QueryableMaintenanceStore.Row::getParentIds)
|
||||
.isEqualTo(new String[]{"42", "earthlings"});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWriteAllForNewParent() {
|
||||
StoreTestBuilder testStoreBuilder = new StoreTestBuilder(connectionString, Repository.class.getName());
|
||||
|
||||
Reference in New Issue
Block a user