Skip to content

CASSJAVA-3 Fix Ordering for LIMIT and PER PARTITION LIMIT on Select Queries #2022

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

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,6 @@ public String asCql() {
}
}

if (limit != null) {
builder.append(" LIMIT ");
if (limit instanceof BindMarker) {
((BindMarker) limit).appendTo(builder);
} else {
builder.append(limit);
}
}

if (perPartitionLimit != null) {
builder.append(" PER PARTITION LIMIT ");
if (perPartitionLimit instanceof BindMarker) {
Expand All @@ -475,6 +466,15 @@ public String asCql() {
}
}

if (limit != null) {
builder.append(" LIMIT ");
if (limit instanceof BindMarker) {
((BindMarker) limit).appendTo(builder);
} else {
builder.append(limit);
}
}

if (allowsFiltering) {
builder.append(" ALLOW FILTERING");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ public void should_use_last_per_partition_limit_if_called_multiple_times() {
assertThat(selectFrom("foo").all().perPartitionLimit(1).perPartitionLimit(2))
.hasCql("SELECT * FROM foo PER PARTITION LIMIT 2");
}

@Test
public void should_put_limit_after_partition_limit() {
assertThat(selectFrom("foo").all().perPartitionLimit(1).limit(1))
.hasCql("SELECT * FROM foo PER PARTITION LIMIT 1 LIMIT 1");
}
}