-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-2652 - Implements deleteAllById. #892
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
70a2370
DATAMONGO-2652 - Prepare branch
schauder 90884e3
DATAMONGO-2652 - Implements CrudRepository.delete(Iterable<ID> ids).
schauder 57e0d0f
DATAMONGO-2652 - Implements deleteAllById.
schauder 8d5ea38
DATAMONGO-2652 - deleteAllById now performs a single query.
schauder 9dab7e1
DATAMONGO-2652 - deleteAll(Iterable) now performs a single query.
schauder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*/ | ||
package org.springframework.data.mongodb.repository; | ||
|
||
import static java.util.Arrays.*; | ||
import static org.assertj.core.api.Assertions.*; | ||
import static org.springframework.data.domain.Sort.Direction.*; | ||
import static org.springframework.data.mongodb.core.query.Criteria.*; | ||
|
@@ -66,7 +67,6 @@ | |
import org.springframework.data.mongodb.test.util.MongoTestUtils; | ||
import org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor; | ||
import org.springframework.data.repository.Repository; | ||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; | ||
import org.springframework.data.repository.query.ReactiveQueryMethodEvaluationContextProvider; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
|
@@ -77,10 +77,12 @@ | |
* | ||
* @author Mark Paluch | ||
* @author Christoph Strobl | ||
* @author Jens Schauder | ||
*/ | ||
@ExtendWith({ MongoClientExtension.class, SpringExtension.class }) | ||
public class ReactiveMongoRepositoryTests { | ||
|
||
public static final int PERSON_COUNT = 7; | ||
static @Client MongoClient mongoClient; | ||
|
||
@Autowired ReactiveMongoTemplate template; | ||
|
@@ -154,17 +156,17 @@ public void setUp() throws Exception { | |
dave = new Person("Dave", "Matthews", 42); | ||
oliver = new Person("Oliver August", "Matthews", 4); | ||
carter = new Person("Carter", "Beauford", 49); | ||
carter.setSkills(Arrays.asList("Drums", "percussion", "vocals")); | ||
carter.setSkills(asList("Drums", "percussion", "vocals")); | ||
Thread.sleep(10); | ||
boyd = new Person("Boyd", "Tinsley", 45); | ||
boyd.setSkills(Arrays.asList("Violin", "Electric Violin", "Viola", "Mandolin", "Vocals", "Guitar")); | ||
boyd.setSkills(asList("Violin", "Electric Violin", "Viola", "Mandolin", "Vocals", "Guitar")); | ||
stefan = new Person("Stefan", "Lessard", 34); | ||
leroi = new Person("Leroi", "Moore", 41); | ||
|
||
alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE); | ||
|
||
repository.saveAll(Arrays.asList(oliver, carter, boyd, stefan, leroi, alicia, dave)).as(StepVerifier::create) // | ||
.expectNextCount(7) // | ||
repository.saveAll(asList(oliver, carter, boyd, stefan, leroi, alicia, dave)).as(StepVerifier::create) // | ||
.expectNextCount(PERSON_COUNT) // | ||
.verifyComplete(); | ||
} | ||
|
||
|
@@ -411,7 +413,7 @@ public void considersRepositoryCollectionName() { | |
|
||
leroi.id = null; | ||
boyd.id = null; | ||
contactRepository.saveAll(Arrays.asList(leroi, boyd)) // | ||
contactRepository.saveAll(asList(leroi, boyd)) // | ||
.as(StepVerifier::create) // | ||
.expectNextCount(2) // | ||
.verifyComplete(); | ||
|
@@ -430,7 +432,7 @@ public void considersRepositoryCollectionName() { | |
@Test // DATAMONGO-2182 | ||
public void shouldFindPersonsWhenUsingQueryDslPerdicatedOnIdProperty() { | ||
|
||
repository.findAll(person.id.in(Arrays.asList(dave.id, carter.id))) // | ||
repository.findAll(person.id.in(asList(dave.id, carter.id))) // | ||
.collectList() // | ||
.as(StepVerifier::create) // | ||
.assertNext(actual -> { | ||
|
@@ -468,7 +470,7 @@ public void annotatedAggregationWithPlaceholderValue() { | |
.contains(new PersonAggregate("Tinsley", "Boyd")) // | ||
.contains(new PersonAggregate("Beauford", "Carter")) // | ||
.contains(new PersonAggregate("Moore", "Leroi")) // | ||
.contains(new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August"))); | ||
.contains(new PersonAggregate("Matthews", asList("Dave", "Oliver August"))); | ||
}).verifyComplete(); | ||
} | ||
|
||
|
@@ -484,7 +486,7 @@ public void annotatedAggregationWithSort() { | |
new PersonAggregate("Beauford", "Carter"), // | ||
new PersonAggregate("Keys", "Alicia"), // | ||
new PersonAggregate("Lessard", "Stefan"), // | ||
new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August")), // | ||
new PersonAggregate("Matthews", asList("Dave", "Oliver August")), // | ||
new PersonAggregate("Moore", "Leroi"), // | ||
new PersonAggregate("Tinsley", "Boyd")); | ||
}) // | ||
|
@@ -501,7 +503,7 @@ public void annotatedAggregationWithPageable() { | |
assertThat(actual) // | ||
.containsExactly( // | ||
new PersonAggregate("Lessard", "Stefan"), // | ||
new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August"))); | ||
new PersonAggregate("Matthews", asList("Dave", "Oliver August"))); | ||
}) // | ||
.verifyComplete(); | ||
} | ||
|
@@ -576,7 +578,7 @@ public void annotatedAggregationSkipsEmptyDocumentsWhenExtractingSimpleValue() { | |
Person p3 = new Person(firstname, null); | ||
p3.setEmail("[email protected]"); | ||
|
||
repository.saveAll(Arrays.asList(p1, p2, p3)).then().as(StepVerifier::create).verifyComplete(); | ||
repository.saveAll(asList(p1, p2, p3)).then().as(StepVerifier::create).verifyComplete(); | ||
|
||
repository.projectToLastnameAndRemoveId(firstname) // | ||
.as(StepVerifier::create) // | ||
|
@@ -617,6 +619,18 @@ public void deleteByShouldAllowSingleDocumentRemovalCorrectly() { | |
.verifyComplete(); | ||
} | ||
|
||
@Test // DATAMONGO-2652 | ||
public void deleteAllById() { | ||
|
||
repository.deleteAllById(asList(carter.id, dave.id)) // | ||
.as(StepVerifier::create) // | ||
.verifyComplete(); | ||
|
||
repository.count().as(StepVerifier::create) // | ||
.expectNext(PERSON_COUNT - 2L) // | ||
.verifyComplete(); | ||
} | ||
|
||
interface ReactivePersonRepository | ||
extends ReactiveMongoRepository<Person, String>, ReactiveQuerydslPredicateExecutor<Person> { | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a single query here. Going to apply that change during the merge.