Skip to content
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

feat(jdbc): add a defaultFilter to revision #1797

Merged
merged 1 commit into from
Jul 24, 2023
Merged
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 @@ -83,7 +83,8 @@ public Optional<Flow> findById(String namespace, String id, Optional<Integer> re
from = context
.select(field("value", String.class))
.from(jdbcRepository.getTable())
.where(field("namespace").eq(namespace))
.where(this.revisionDefaultFilter())
.and(field("namespace").eq(namespace))
.and(field("id", String.class).eq(id))
.and(field("revision", Integer.class).eq(revision.get()));
} else {
Expand All @@ -99,6 +100,10 @@ public Optional<Flow> findById(String namespace, String id, Optional<Integer> re
});
}

protected Condition revisionDefaultFilter() {
return DSL.trueCondition();
}

@Override
public Optional<FlowWithSource> findByIdWithSource(String namespace, String id, Optional<Integer> revision) {
return jdbcRepository
Expand All @@ -113,7 +118,8 @@ public Optional<FlowWithSource> findByIdWithSource(String namespace, String id,
field("value", String.class)
)
.from(jdbcRepository.getTable())
.where(field("namespace").eq(namespace))
.where(this.revisionDefaultFilter())
.and(field("namespace").eq(namespace))
.and(field("id", String.class).eq(id))
.and(field("revision", Integer.class).eq(integer)))
.orElseGet(() -> context
Expand Down Expand Up @@ -150,7 +156,8 @@ public List<FlowWithSource> findRevisions(String namespace, String id) {
field("value", String.class)
)
.from(jdbcRepository.getTable())
.where(field("namespace", String.class).eq(namespace))
.where(this.revisionDefaultFilter())
.and(field("namespace", String.class).eq(namespace))
.and(field("id", String.class).eq(id))
.orderBy(field("revision", Integer.class).asc());

Expand Down