fix: Updating the MS-SQL select query template to use TOP instead of LIMIT since LIMIT is not supported in the same. (#9082)

This commit is contained in:
Trisha Anand 2021-11-12 10:48:43 +05:30 committed by GitHub
parent 4e1e531a24
commit 94f312726b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -1 +1 @@
SELECT * FROM users where role = {{ roleDropdown.selectedOptionValue }} ORDER BY id LIMIT 10;
SELECT TOP 10 * FROM users where role = {{ roleDropdown.selectedOptionValue }} ORDER BY id;

View File

@ -590,4 +590,32 @@ public class MssqlPluginTest {
})
.verifyComplete();
}
@Test
public void testLimitQuery() {
DatasourceConfiguration dsConfig = createDatasourceConfiguration();
ActionConfiguration actionConfiguration = new ActionConfiguration();
// First test with the binding not surrounded with quotes
actionConfiguration.setBody("SELECT TOP 10 * FROM users ORDER BY id;");
List<Property> pluginSpecifiedTemplates = new ArrayList<>();
pluginSpecifiedTemplates.add(new Property("preparedStatement", "true"));
actionConfiguration.setPluginSpecifiedTemplates(pluginSpecifiedTemplates);
ExecuteActionDTO executeActionDTO = new ExecuteActionDTO();
List<Param> params = new ArrayList<>();
executeActionDTO.setParams(params);
Mono<Connection> connectionCreateMono = pluginExecutor.datasourceCreate(dsConfig).cache();
Mono<ActionExecutionResult> resultMono = connectionCreateMono
.flatMap(pool -> pluginExecutor.executeParameterized(pool, executeActionDTO, dsConfig, actionConfiguration));
StepVerifier.create(resultMono)
.assertNext(result -> {
assertTrue(result.getIsExecutionSuccess());
})
.verifyComplete();
}
}