Skip to content

Commit efcf1ca

Browse files
dkasimovskiyclaude
andcommitted
fix(crud): inject default opts into varargs upsert
The varargs \`upsert(Options, Object...)\` and \`upsertObject(Options, Object...)\` overloads forwarded their \`arguments\` straight to \`iprotoCall\`, producing a 3-arg wire call \`crud.upsert(space, tuple, operations)\` with no opts table. CRUD rock 1.5.0+ (bundled with Tarantool 3.5.0) rejects that 3-arg form at \`crud/compare/conditions.lua:93\` with \`ParseConditionError: Each condition should be table, got "string" (condition 1)\`. The 4-arg form \`(space, tuple, operations, opts)\` works because that overload delegates through \`toTupleOperationsOptsArgs\`. Fix: append \`DEFAULT_UPDATE_OPTIONS.getOptions()\` to the args when the caller has not already supplied an opts map (last varargs element not a \`Map\`). The guard preserves the existing 4-arg call from \`testUpsertParameters\`, which deliberately passes its own options map. Fixes \`TarantoolCrudClientTest#testUpsert\` on Tarantool 3.5.0. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c76d799 commit efcf1ca

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
- Upgrade TQE to v3.5.0.
1616
- Extract `ObjectMapper` to a static field in the test `tdg.Utils` helper to avoid recreating it on every `sendUsers`/`getUsers` call.
1717

18+
### Client
19+
20+
- Append a default opts map to the varargs `upsert`/`upsertObject` calls so the request reaches the CRUD rock as the 4-arg form; CRUD 1.5.0+'s conditions parser rejects the legacy 3-arg form with `ParseConditionError`.
21+
1822
### Documentation
1923

2024
- Document supported Java types for Tarantool data mapping in `tuple_pojo_mapping` docs (RU/EN), including Tarantool extension types (`decimal`, `uuid`, `datetime`, `interval`, `tuple`) and related mapping notes.

tarantool-client/src/main/java/io/tarantool/client/factory/TarantoolCrudSpaceImpl.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,14 @@ public <T> CompletableFuture<Tuple<T>> update(
726726

727727
@Override
728728
public CompletableFuture<Void> upsert(Options options, Object... arguments) {
729-
return crudCallSingleResult(options, CRUD_UPSERT, arguments).thenAccept((r) -> {});
729+
Object[] args = ensureOpts(arguments, DEFAULT_UPDATE_OPTIONS.getOptions());
730+
return crudCallSingleResult(options, CRUD_UPSERT, args).thenAccept((r) -> {});
730731
}
731732

732733
@Override
733734
public CompletableFuture<Void> upsertObject(Options options, Object... arguments) {
734-
return crudCallSingleResult(options, CRUD_UPSERT_OBJECT, arguments).thenAccept((r) -> {});
735+
Object[] args = ensureOpts(arguments, DEFAULT_UPDATE_OPTIONS.getOptions());
736+
return crudCallSingleResult(options, CRUD_UPSERT_OBJECT, args).thenAccept((r) -> {});
735737
}
736738

737739
@Override
@@ -897,6 +899,14 @@ private Object[] toTupleOperationsOptsArgs(
897899
return new Object[] {tuple, operations, options.getOptions()};
898900
}
899901

902+
// CRUD 1.5.0+ needs an opts table; append a default one when the caller didn't supply it.
903+
private static Object[] ensureOpts(Object[] args, Map<String, Object> defaultOpts) {
904+
if (args.length > 0 && args[args.length - 1] instanceof Map) return args;
905+
Object[] withOpts = Arrays.copyOf(args, args.length + 1);
906+
withOpts[args.length] = defaultOpts;
907+
return withOpts;
908+
}
909+
900910
/**
901911
* Converts key, operations and options to array of arguments.
902912
*

tarantool-shared-resources/vshard_cluster/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ WORKDIR "$TARANTOOL_WORKDIR/$APP_NAME"
1313
RUN mkdir -p /etc/tarantool/instances.enabled && \
1414
ln -s "$TARANTOOL_WORKDIR/$APP_NAME" /etc/tarantool/instances.enabled/app
1515

16-
RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirror.yandex.ru/ubuntu/|g; s|http://security.ubuntu.com/ubuntu/|http://mirror.yandex.ru/ubuntu/|g' /etc/apt/sources.list
17-
18-
# install dependencies
1916
RUN apt-get -y update && \
2017
apt-get -y install build-essential cmake make gcc git unzip && \
2118
apt-get -y clean

0 commit comments

Comments
 (0)