Skip to content

Commit

Permalink
Merge pull request #804 from 9tigerio/feature/800_support_oracle_stor…
Browse files Browse the repository at this point in the history
…ed_procedure

Fix oracle db stored procedure call
  • Loading branch information
souravroy authored Nov 20, 2024
2 parents 7b0cd7f + 94b8f9e commit c8cf3af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.homihq.db2rest.rest.oracle;

import com.homihq.db2rest.MySQLBaseIntegrationTest;
import com.homihq.db2rest.OracleBaseIntegrationTest;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.ClassOrderer;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestClassOrder;
import org.springframework.http.MediaType;

import java.util.Map;

import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand All @@ -19,7 +24,6 @@
@Order(250)
class OracleProcedureControllerTest extends OracleBaseIntegrationTest {

@Disabled
@Test
@DisplayName("Execute stored procedure on oracle db")
void execute() throws Exception {
Expand All @@ -36,8 +40,8 @@ void execute() throws Exception {
.content(json))
.andExpect(status().isOk())
.andExpect(jsonPath("$", instanceOf(Map.class)))
.andExpect(jsonPath("$.*", hasSize(2)))
.andExpect(jsonPath("$.rentalRate", equalTo(0.99)))
.andExpect(jsonPath("$.*", hasSize(1)))
.andExpect(jsonPath("$.P_RENTAL_RATE", equalTo(0.99)))
//.andDo(print())
.andDo(document("oracle-execute-procedure"));
}
Expand Down
2 changes: 1 addition & 1 deletion api-rest/src/test/resources/oracle/oracle-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -779,4 +779,4 @@ WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20002,
'Error getting rental rate: ' || SQLERRM);
END GetMovieRentalRateProc;
/

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;

import java.util.Map;
Expand All @@ -33,9 +31,8 @@ public Map<String, Object> execute(String dbId, String subRoutineName, Map<Strin
}

private Map<String, Object> doExecuteInternal(JdbcTemplate jdbcTemplate,
String subRoutineName, Map<String, Object> inParams) {
String subRoutineName, Map<String, Object> inParams) {
jdbcTemplate.setResultsMapCaseInsensitive(true);
SqlParameterSource in = new MapSqlParameterSource().addValues(inParams);

try {
return new SimpleJdbcCall(jdbcTemplate).withProcedureName(subRoutineName).execute(inParams);
Expand Down

0 comments on commit c8cf3af

Please sign in to comment.