Skip to content

Was not using QueryContext in tx when scope=_default, but collection!… #1746

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

Merged
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 @@ -15,6 +15,7 @@
*/
package org.springframework.data.couchbase.core;

import com.couchbase.client.core.api.query.CoreQueryContext;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -194,7 +195,7 @@ public Flux<T> all() {
TransactionQueryOptions opts = buildTransactionOptions(pArgs.getOptions());
JsonSerializer jSer = clientFactory.getCluster().environment().jsonSerializer();
return AttemptContextReactiveAccessor.createReactiveTransactionAttemptContext(s.get().getCore(), jSer)
.query(rs.name().equals(CollectionIdentifier.DEFAULT_SCOPE) ? null : rs, statement, opts);
.query(OptionsBuilder.queryContext(pArgs.getScope(), pArgs.getCollection(), rs.bucketName()) == null ? null : rs, statement, opts);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Flux<RemoveResult> all() {
} else {
TransactionQueryOptions opts = OptionsBuilder
.buildTransactionQueryOptions(buildQueryOptions(pArgs.getOptions()));
CoreQueryContext queryContext = CollectionIdentifier.DEFAULT_SCOPE.equals(rs.name()) ? null : CoreQueryContext.of(rs.bucketName(), rs.name());
CoreQueryContext queryContext = OptionsBuilder.queryContext(pArgs.getScope(), pArgs.getCollection(), rs.bucketName());
return transactionContext.get().getCore()
.queryBlocking(statement, queryContext, opts.builder().build(), false)
.flatMapIterable(result -> result.collectRows()).map(row -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,11 @@ public static ScanOptions buildScanOptions(ScanOptions options, Object sort, Boo
}
return options;
}

public static CoreQueryContext queryContext(String scope, String collection, String bucketName) {
return (scope == null || CollectionIdentifier.DEFAULT_SCOPE.equals(scope))
&& (collection == null || CollectionIdentifier.DEFAULT_COLLECTION.equals(collection)) ? null
: CoreQueryContext.of(bucketName, scope);
}
}
}
Loading