Skip to content

Commit

Permalink
feat(jdbc): add a defaultFilter to revision
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Jul 24, 2023
1 parent 033d3fe commit fc5a8e9
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit fc5a8e9

Please sign in to comment.