fix: mongo schema collections order of mongo plugin (#36062)
### PR Description: - **File changes in the PR**: - Integrated the sorting feature to the mongo collections. - Added the unit test for sorting. Fixes https://github.com/appsmithorg/appsmith/issues/35842 - **Snapshots**: **Before resolving bug:**  **After resolving bug:**  <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced the MongoDB plugin to return collection names in a case-insensitive sorted order, improving predictability and user experience. - **Tests** - Added a new test to validate that collections returned by the plugin are sorted correctly, ensuring consistent functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
73169d13b0
commit
cdb22f4dfd
|
|
@ -964,6 +964,7 @@ public class MongoPlugin extends BasePlugin {
|
|||
}
|
||||
return true;
|
||||
})
|
||||
.sort((collectionName1, collectionName2) -> collectionName1.compareToIgnoreCase(collectionName2))
|
||||
.flatMap(collectionName -> {
|
||||
final ArrayList<DatasourceStructure.Column> columns = new ArrayList<>();
|
||||
final ArrayList<DatasourceStructure.Template> templates = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -655,6 +655,26 @@ public class MongoPluginQueriesTest {
|
|||
.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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user