Skip to content

Commit

Permalink
fix: remove simple quotes from N1QL identifiers during conversion; Cl…
Browse files Browse the repository at this point in the history
…oses #381

Signed-off-by: Maximillian Arruda <dearrudam@gmail.com>
  • Loading branch information
dearrudam committed May 23, 2023
1 parent 97bb258 commit 7e07773
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void condition(DocumentCondition condition, StringBuilder n1ql, JsonObje
private void predicateBetween(StringBuilder n1ql, JsonObject params, Document document) {
n1ql.append(" BETWEEN ");
ThreadLocalRandom random = ThreadLocalRandom.current();
String name = '\'' + document.name() + '\'';
String name = identifierOf(document.name());

List<Object> values = new ArrayList<>();
((Iterable<?>) document.get()).forEach(values::add);
Expand All @@ -162,13 +162,17 @@ private void predicate(StringBuilder n1ql,
Document document,
JsonObject params) {
ThreadLocalRandom random = ThreadLocalRandom.current();
String name = '\'' + document.name() + '\'';
String name = identifierOf(document.name());
Object value = document.get();
String param = "$".concat(document.name()).concat("_").concat(Integer.toString(random.nextInt(0, 100)));
n1ql.append(name).append(condition).append(param);
params.put(param, value);
}

private String identifierOf(String name) {
return ' ' + name + ' ';
}

private String select() {
String documents = query.documents().stream()
.collect(Collectors.joining(", "));
Expand Down

0 comments on commit 7e07773

Please sign in to comment.