Skip to content

N1QLExpression#keys is broken #1064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aaronjwhiteside opened this issue Jan 21, 2021 · 0 comments · Fixed by #1113 or #1115
Closed

N1QLExpression#keys is broken #1064

aaronjwhiteside opened this issue Jan 21, 2021 · 0 comments · Fixed by #1113 or #1115
Labels
type: bug A general bug

Comments

@aaronjwhiteside
Copy link
Contributor

aaronjwhiteside commented Jan 21, 2021

Backstory:
We use N1QLExpression to implement a custom base repository.

Issue:
If a collection of keys are passed in invalid n1ql is generated.

expression.keys(Arrays.asList("hello", "world"));

would generate

USE KEYS `hello`, `world` 

instead of the valid

USE KEYS ["hello", "world"]

Solution: (from our workaround)

    public N1QLExpression keys(Iterable<? extends Serializable> ids) {
        StringBuilder sb = new StringBuilder();
        Iterator<?> it = ids.iterator();
        int count = 0;
        while (it.hasNext()) {
            count++;
            sb.append(s(it.next().toString()));
            if (it.hasNext()) {
                sb.append(",");
            }
        }
        return infix("USE KEYS", toString(), count > 1 ? "[" + sb.toString() + "]" : sb.toString());
    }
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 21, 2021
@aaronjwhiteside aaronjwhiteside changed the title N1QLExpression#keys is broken when more than a single key is passed in N1QLExpression#keys is broken Jan 22, 2021
@mikereiche mikereiche added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 4, 2021
mikereiche added a commit that referenced this issue Mar 29, 2021
Fix syntax for USE KEYS [ ... ]

Closed #1064.
Original pull request: #1112.
mikereiche added a commit that referenced this issue Mar 30, 2021
Fix syntax for USE KEYS [ ... ]

Closes #1064.
Original pull request: #1113.

Co-authored-by: mikereiche <[email protected]>
mikereiche added a commit that referenced this issue Mar 30, 2021
Fix syntax for USE KEYS [ ... ]

Closes #1064.
Original pull request: #1113.

Co-authored-by: mikereiche <[email protected]>
mikereiche added a commit that referenced this issue Mar 30, 2021
Fix syntax for USE KEYS [ ... ]

Closes #1064.
Original pull request: #1112.
mikereiche added a commit that referenced this issue Mar 30, 2021
mikereiche added a commit that referenced this issue Mar 31, 2021
Fix syntax of N1QLExpression keys.

Closes #1064.

Co-authored-by: mikereiche <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
3 participants