Skip to content

Commit 9b1cd64

Browse files
babltigamikereiche
authored andcommitted
Fixed issue with #n1ql.bucket evaluated as collection name in string based queries. (#1804)
Closes #1799
1 parent 2a4aa5e commit 9b1cd64

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/java/org/springframework/data/couchbase/repository/query/StringBasedN1qlQueryParser.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
/**
6363
* @author Subhashni Balakrishnan
6464
* @author Michael Reiche
65+
* @author Tigran Babloyan
6566
*/
6667
public class StringBasedN1qlQueryParser {
6768
public static final String SPEL_PREFIX = "n1ql";
@@ -166,7 +167,7 @@ public StringBasedN1qlQueryParser(String statement, CouchbaseQueryMethod queryMe
166167
this.queryMethod = queryMethod;
167168
this.couchbaseConverter = couchbaseConverter;
168169
this.statementContext = queryMethod == null ? null
169-
: createN1qlSpelValues(collection != null ? collection : bucketName, scope, collection,
170+
: createN1qlSpelValues(bucketName, scope, collection,
170171
queryMethod.getEntityInformation().getJavaType(), typeField, typeValue, queryMethod.isCountQuery(), null, null);
171172
this.parsedExpression = getExpression(statement, queryMethod, accessor, spelExpressionParser,
172173
evaluationContextProvider);

src/test/java/org/springframework/data/couchbase/repository/query/StringN1qlQueryCreatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void spelTests() throws Exception {
208208

209209
assertEquals("SELECT `_class`, `jsonNode`, `jsonObject`, `jsonArray`, META(`myCollection`).`cas`"
210210
+ " AS __cas, `createdBy`, `createdDate`, `lastModifiedBy`, `lastModifiedDate`, META(`myCollection`).`id`"
211-
+ " AS __id, `firstname`, `lastname`, `subtype` FROM `myCollection`|`_class` = \"abstractuser\"|`myCollection`|`myScope`|`myCollection`",
211+
+ " AS __id, `firstname`, `lastname`, `subtype` FROM `myCollection`|`_class` = \"abstractuser\"|`some_bucket`|`myScope`|`myCollection`",
212212
query.toN1qlSelectString(converter, bucketName(), "myScope", "myCollection", User.class, null, false, null,
213213
null));
214214
}

0 commit comments

Comments
 (0)