Skip to content

feat(queryapi): add support for TransactionType.UNCONSTRAINED #28

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
merged 1 commit into from
Jun 9, 2025
Merged
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 @@ -26,7 +26,6 @@
import org.neo4j.bolt.connection.AccessMode;
import org.neo4j.bolt.connection.LoggingProvider;
import org.neo4j.bolt.connection.ResponseHandler;
import org.neo4j.bolt.connection.TransactionType;
import org.neo4j.bolt.connection.exception.BoltClientException;
import org.neo4j.bolt.connection.message.BeginMessage;
import org.neo4j.bolt.connection.values.ValueFactory;
Expand Down Expand Up @@ -55,9 +54,6 @@ final class BeginMessageHandler extends AbstractMessageHandler<TransactionInfo>
throw new BoltClientException("Database name must be specified");
}

if (message.transactionType() != TransactionType.DEFAULT) {
throw new BoltClientException("Only TransactionType.DEFAULT is supported");
}
try {
this.bodyPublisher = newHttpRequestBodyPublisher(httpContext, message, this.databaseName);
} catch (IOException e) {
Expand Down Expand Up @@ -94,21 +90,29 @@ protected TransactionInfo handleResponse(HttpResponse<String> response) {
private static HttpRequest.BodyPublisher newHttpRequestBodyPublisher(
HttpContext httpContext, BeginMessage message, String databaseName) throws IOException {

String accessMode = message.accessMode() == AccessMode.READ ? "Read" : null;
String impersonatedUser = message.impersonatedUser().orElseGet(() -> null);
var accessMode = message.accessMode() == AccessMode.READ ? "Read" : null;
var impersonatedUser = message.impersonatedUser().orElse(null);
List<String> bookmarks = null;

if (!message.bookmarks().isEmpty()) {
bookmarks = new ArrayList<>(message.bookmarks());
}

var jsonBody = httpContext.json().asString(new BeginMessageWrapper(accessMode, impersonatedUser, bookmarks));
var txType = message.transactionType() != null
? switch (message.transactionType()) {
case UNCONSTRAINED -> "IMPLICIT";
case DEFAULT -> null;
}
: null;

var jsonBody =
httpContext.json().asString(new BeginMessageWrapper(accessMode, impersonatedUser, bookmarks, txType));
return HttpRequest.BodyPublishers.ofString(jsonBody);
}

record TransactionEntry(Transaction transaction) {}

record Transaction(String id, String expires) {}

record BeginMessageWrapper(String accessMode, String impersonatedUser, List<String> bookmarks) {}
record BeginMessageWrapper(String accessMode, String impersonatedUser, List<String> bookmarks, String txType) {}
}