Skip to content
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 @@ -725,4 +725,26 @@ void shouldGenerateQueryForParentWorkflowId() throws SQLException {
inOrder.verify(mockQuery).addParameter(0);
verifyNoMoreInteractions(mockQuery);
}

@Test
void shouldSortOnWorkflowTypeWhichBacksTheAgentNameColumn() throws SQLException {
PostgresIndexQueryBuilder builder =
new PostgresIndexQueryBuilder(
"workflow_index", "", "", 0, 15, List.of("workflowType:ASC"), properties);
assertEquals(
"SELECT json_data::TEXT FROM workflow_index ORDER BY workflow_type ASC LIMIT ? OFFSET ?",
builder.getQuery());
}

@Test
void shouldDropSortFieldsThatAreNotIndexedColumns() throws SQLException {
// A sort field outside VALID_FIELDS produces no ORDER BY at all rather than an
// error, so LIMIT/OFFSET pages an unordered result set. Callers must send the
// indexed column name -- `workflowType`, not `workflowName`. See issue #1514.
PostgresIndexQueryBuilder builder =
new PostgresIndexQueryBuilder(
"workflow_index", "", "", 0, 15, List.of("workflowName:ASC"), properties);
assertEquals(
"SELECT json_data::TEXT FROM workflow_index LIMIT ? OFFSET ?", builder.getQuery());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,25 @@ void shouldGenerateQueryForParentWorkflowId() throws SQLException {
inOrder.verify(mockQuery).addParameter(0);
verifyNoMoreInteractions(mockQuery);
}

@Test
void shouldSortOnWorkflowTypeWhichBacksTheAgentNameColumn() throws SQLException {
SqliteIndexQueryBuilder builder =
new SqliteIndexQueryBuilder(
"workflow_index", "", "", 0, 15, List.of("workflowType:ASC"), properties);
assertEquals(
"SELECT json_data FROM workflow_index ORDER BY workflow_type ASC LIMIT ? OFFSET ?",
builder.getQuery());
}

@Test
void shouldDropSortFieldsThatAreNotIndexedColumns() throws SQLException {
// A sort field outside VALID_FIELDS produces no ORDER BY at all rather than an
// error, so LIMIT/OFFSET pages an unordered result set. Callers must send the
// indexed column name -- `workflowType`, not `workflowName`. See issue #1514.
SqliteIndexQueryBuilder builder =
new SqliteIndexQueryBuilder(
"workflow_index", "", "", 0, 15, List.of("workflowName:ASC"), properties);
assertEquals("SELECT json_data FROM workflow_index LIMIT ? OFFSET ?", builder.getQuery());
}
}
Loading