Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oracle db stored procedure call #804

Merged
merged 1 commit into from
Nov 20, 2024
Merged
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
@@ -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