Skip to content

DATACOUCH-28 - Remove explicit setting of setIncludeDocs on View queries. #8

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 @@ -103,8 +103,9 @@ public interface CouchbaseOperations {
/**
* Query a View for a list of documents of type T.
*
* <p>There is no need to {@link Query#setIncludeDocs(boolean)} explicitely, because it will be set to true all the
* time. It is valid to pass in a empty constructed {@link Query} object.</p>
* {@link Query#setIncludeDocs(boolean)} defaults to false. If you require the query to include the entire
* document, you will need to set it to true before calling this method. It is valid to pass in a empty
* constructed {@link Query} object.
*
* <p>This method does not work with reduced views, because they by design do not contain references to original
* objects. Use the provided {@link #queryView} method for more flexibility and direct access.</p>
Expand All @@ -130,7 +131,7 @@ public interface CouchbaseOperations {
* @param design the name of the design document.
* @param view the name of the view.
* @param query the Query object to customize the view query.
* @return
* @return the view response.
*/
ViewResponse queryView(String design, String view, Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ public String doInBucket() {
public <T> List<T> findByView(final String designName, final String viewName,
final Query query, final Class<T> entityClass) {

if (!query.willIncludeDocs()) {
query.setIncludeDocs(true);
}
if (query.willReduce()) {
query.setReduce(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public Iterable<T> findAll() {
String design = entityInformation.getJavaType().getSimpleName().toLowerCase();
String view = "all";

return couchbaseOperations.findByView(design, view, new Query().setReduce(false),
return couchbaseOperations.findByView(design, view, new Query().setIncludeDocs(true).setReduce(false),
entityInformation.getJavaType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public void validFindById() {
@Test
public void shouldLoadAndMapViewDocs() {
Query query = new Query();
query.setIncludeDocs(true);
query.setStale(Stale.FALSE);

final List<Beer> beers = template.findByView("test_beers", "by_name", query, Beer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void simpleCrud() {
@Test
public void shouldFindAll() {
// do a non-stale query to populate data for testing.
client.query(client.getView("user", "all"), new Query().setStale(Stale.FALSE));
client.query(client.getView("user", "all"), new Query().setIncludeDocs(true).setStale(Stale.FALSE));

Iterable<User> allUsers = repository.findAll();
int size = 0;
Expand Down