Skip to content

Commit

Permalink
fix: backticks CB attributes in N1QL (#2313)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
yuremm and yurem committed Sep 6, 2022
1 parent de9d00a commit d6db13d
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private <O> PagedResult<JsonObject> searchImpl(BucketMapping bucketMapping, Stri
}
}

StringBuilder baseQuery = new StringBuilder("SELECT ").append(StringHelper.toString(select)).append(" FROM `").append(bucketMapping.getBucketName()).append("` AS gluu_doc ").
StringBuilder baseQuery = new StringBuilder("SELECT ").append(StringHelper.toString(backticksAttributes(select))).append(" FROM `").append(bucketMapping.getBucketName()).append("` AS gluu_doc ").
append("WHERE ").append(finalExpression);

StringBuilder baseQueryWithOrder = new StringBuilder(baseQuery);
Expand Down Expand Up @@ -617,6 +617,19 @@ private <O> PagedResult<JsonObject> searchImpl(BucketMapping bucketMapping, Stri
return result;
}

private String[] backticksAttributes(String[] attributes) {
if (ArrayHelper.isEmpty(attributes)) {
return attributes;
}

String[] resultAttributes = new String[attributes.length];
for (int i = 0; i < attributes.length; i++) {
resultAttributes[i] = '`' + attributes[i] + "`";
}

return resultAttributes;
}

public String[] createStoragePassword(String[] passwords) {
if (ArrayHelper.isEmpty(passwords)) {
return passwords;
Expand Down

0 comments on commit d6db13d

Please sign in to comment.