mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-12-19 06:53:45 +00:00
Fix UpdateQuery.Builder to allow only a scriptname to be set.
Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
This commit is contained in:
parent
e31b66768b
commit
69746441e1
@ -438,8 +438,8 @@ public class UpdateQuery {
|
||||
|
||||
public UpdateQuery build() {
|
||||
|
||||
if (script == null && document == null && query == null) {
|
||||
throw new IllegalArgumentException("either script, document or query must be set");
|
||||
if (script == null && scriptName == null && document == null && query == null) {
|
||||
throw new IllegalArgumentException("either script, scriptName, document or query must be set");
|
||||
}
|
||||
|
||||
return new UpdateQuery(id, script, params, document, upsert, lang, routing, scriptedUpsert, docAsUpsert,
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
|
||||
class UpdateQueryTest {
|
||||
|
||||
@Test // #3205
|
||||
@DisplayName("should build query with only a script")
|
||||
void shouldBuildQueryWithOnlyAScript() {
|
||||
|
||||
UpdateQuery.builder("id")
|
||||
.withScript("script")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test // #3205
|
||||
@DisplayName("should build query with only a scriptname")
|
||||
void shouldBuildQueryWithOnlyAScriptName() {
|
||||
|
||||
UpdateQuery.builder("id")
|
||||
.withScriptName("scriptname")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test // #3205
|
||||
@DisplayName("should build query with only a document")
|
||||
void shouldBuildQueryWithOnlyASDocument() {
|
||||
|
||||
UpdateQuery.builder("id")
|
||||
.withDocument(Document.create())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test // #3205
|
||||
@DisplayName("should build query with only a query")
|
||||
void shouldBuildQueryWithOnlyAQuery() {
|
||||
|
||||
Query query = StringQuery.builder("StrignQuery").build();
|
||||
|
||||
UpdateQuery.builder(query)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user