Skip to content

Commit

Permalink
fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql … (
Browse files Browse the repository at this point in the history
#4697)

* fix(SqlExecutionRepository): fixed bug in sql repository in orca-sql module

* test(sql): demonstrate behavior of retrievePipelinesForApplication

which also verifies the behavior of selectExections when cursor is null

---------

Co-authored-by: David Byron <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent a27e88a commit fc072b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1119,12 +1119,16 @@ class SqlExecutionRepository(
type,
conditions = {
if (cursor == null) {
it.where("1=1")
if (where == null) {
it.where("1=1")
} else {
where(it)
}
} else {
if (where == null) {
it.where(field("id").gt(cursor))
it.where(field("id").lt(cursor))
} else {
where(it).and(field("id").gt(cursor))
where(it).and(field("id").lt(cursor))
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ abstract class OldPipelineCleanupPollingNotificationAgentSpec extends Specificat
def allExecutions = executionRepository.retrievePipelinesForApplication(app).toList().toBlocking().first().unique()

then:
allExecutions.size() == 10
allExecutions.size() == 12

when:
cleanupAgent.tick()
Expand All @@ -125,7 +125,7 @@ abstract class OldPipelineCleanupPollingNotificationAgentSpec extends Specificat
def allExecutions = executionRepository.retrievePipelinesForApplication(app).toList().toBlocking().first().unique()

then:
allExecutions.size() == 10
allExecutions.size() == 12

when:
cleanupAgent.tick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ class SqlExecutionRepositoryTest : JUnit5Minutests {
assertThat(actualPipelineExecution).isEqualTo(pipelineExecution)
}
}

context("retrievePipelinesForApplication") {
val pipelineExecution1 = PipelineExecutionImpl(ExecutionType.PIPELINE, "application-1")
val pipelineExecution2 = PipelineExecutionImpl(ExecutionType.PIPELINE, "application-2")

test("correctly use where clause") {
// Store pipelines in two different applications
sqlExecutionRepository.store(pipelineExecution1)
sqlExecutionRepository.store(pipelineExecution2)

val observable = sqlExecutionRepository.retrievePipelinesForApplication("application-2")
val executions = observable.toList().toBlocking().single()
assertThat(executions.map(PipelineExecution::getApplication).single()).isEqualTo("application-2")
}
}
}

private inner class Fixture {
Expand Down

0 comments on commit fc072b3

Please sign in to comment.