mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-12-19 15:03:47 +00:00
Fix UpdateQuery.Builder to allow only a scriptname to be set.
Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com> (cherry picked from commit 69746441e1341434d0a795b568ff205c25f652f1)
This commit is contained in:
parent
b3bd77aa46
commit
6260f278ba
@ -438,8 +438,8 @@ public class UpdateQuery {
|
|||||||
|
|
||||||
public UpdateQuery build() {
|
public UpdateQuery build() {
|
||||||
|
|
||||||
if (script == null && document == null && query == null) {
|
if (script == null && scriptName == null && document == null && query == null) {
|
||||||
throw new IllegalArgumentException("either script, document or query must be set");
|
throw new IllegalArgumentException("either script, scriptName, document or query must be set");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new UpdateQuery(id, script, params, document, upsert, lang, routing, scriptedUpsert, docAsUpsert,
|
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