Skip to content

Commit

Permalink
Merge branch 'fix/mongo-schema-collections-order' of github.com:raush…
Browse files Browse the repository at this point in the history
…an3737/appsmith into chore/issue-35842/shadow-36062
  • Loading branch information
NilanshBansal committed Sep 25, 2024
2 parents a93e87b + 42a1c8e commit 24afc69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ public Mono<DatasourceStructure> getStructure(
}
return true;
})
.sort((collectionName1, collectionName2) -> collectionName1.compareToIgnoreCase(collectionName2))
.flatMap(collectionName -> {
final ArrayList<DatasourceStructure.Column> columns = new ArrayList<>();
final ArrayList<DatasourceStructure.Template> templates = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,26 @@ public void testStructure() {
.verifyComplete();
}

@Test
public void testStructure_should_return_collections_in_order() {
DatasourceConfiguration dsConfig = createDatasourceConfiguration();
Mono<DatasourceStructure> structureMono = pluginExecutor
.datasourceCreate(dsConfig)
.flatMap(connection -> pluginExecutor.getStructure(connection, dsConfig, null));

StepVerifier.create(structureMono)
.assertNext(structure -> {
assertNotNull(structure);
assertEquals(3, structure.getTables().size());

// Check that the tables are sorted in ascending order
assertEquals("address", structure.getTables().get(0).getName());
assertEquals("teams", structure.getTables().get(1).getName());
assertEquals("users", structure.getTables().get(2).getName());
})
.verifyComplete();
}

@Test
public void testCountCommand() {
DatasourceConfiguration dsConfig = createDatasourceConfiguration();
Expand Down

0 comments on commit 24afc69

Please sign in to comment.