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

Stored procedure call returns wrong BigDecimal scale. #2559

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c5f6df
Stored procedure call returns wrong BigDecimal scale.
Ananya2 Dec 6, 2024
fdbda10
Removed try block
Ananya2 Dec 6, 2024
4ab4e5c
Added try-catch block
Ananya2 Dec 6, 2024
44e3aaf
Updated testJdbc41CallableStatementMethods test case for BigDecimal c…
Ananya2 Dec 6, 2024
0c0b4f1
Added test case to validate the BigDecimal precision.
Ananya2 Dec 9, 2024
3c2256f
Updated stored procedure statement test.
Ananya2 Dec 9, 2024
a09a497
Fixed pipeline failure
Ananya2 Dec 9, 2024
c531274
Added 'warning' level log in case of failure while fetching scale for…
Ananya2 Dec 9, 2024
95c9628
throws SQLServerException
Ananya2 Dec 9, 2024
d4859f1
Throw SQLServerException on failure.
Ananya2 Dec 9, 2024
1506f62
Added test case testRegisterOutParameterWithDecimalException
Ananya2 Dec 9, 2024
82546f7
Fixed pipeline failure
Ananya2 Dec 9, 2024
e58a9b7
Updated SQLServerCallableStatement.java
Ananya2 Dec 9, 2024
5815afa
removed test case.
Ananya2 Dec 10, 2024
66d8aad
Removed unused import.
Ananya2 Dec 10, 2024
9581f6b
Created BigDecimalPrecisionTest.java file
Ananya2 Dec 10, 2024
28e4505
Fix: Throw SQLServerException with detailed message for metadata retr…
Ananya2 Dec 11, 2024
a07e707
Add test for BigDecimal precision failure when fetching scale metadata.
Ananya2 Dec 11, 2024
33e6d00
Update SQLServerCallableStatement.java
Ananya2 Dec 11, 2024
222dddc
Update BigDecimalPrecisionTest.java
Ananya2 Dec 11, 2024
67064f5
Drop stored procedure if it exists in init()
Ananya2 Dec 16, 2024
6379d57
Update BigDecimalPrecisionTest.java
Ananya2 Dec 16, 2024
ed0ff76
Added detailed comments to the `registerOutParameter` method to expla…
Ananya2 Dec 20, 2024
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
Expand Up @@ -23,6 +23,7 @@
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.ParameterMetaData;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.util.Calendar;
Expand Down Expand Up @@ -150,6 +151,16 @@ public void registerOutParameter(int index, int sqlType) throws SQLServerExcepti
case microsoft.sql.Types.DATETIMEOFFSET:
param.setOutScale(7);
break;
case java.sql.Types.DECIMAL:
ParameterMetaData parameterMetaData = this.getParameterMetaData();
if (parameterMetaData != null) {
try {
// Fetch scale from metadata for DECIMAL type
int scale = parameterMetaData.getScale(index);
param.setOutScale(scale);
} catch (SQLException e) {}
Ananya2 marked this conversation as resolved.
Show resolved Hide resolved
}
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,15 +1195,14 @@ public void testJdbc41CallableStatementMethods() throws Exception {
assertEquals("2017-05-19 10:47:15.1234567 +02:00",
cstmt.getObject("col14Value", microsoft.sql.DateTimeOffset.class).toString());

// BigDecimal#equals considers the number of decimal places (OutParams always return 4 decimal
// digits rounded up)
assertEquals(0, cstmt.getObject(15, BigDecimal.class).compareTo(new BigDecimal("0.1235")));
// BigDecimal#equals considers the number of decimal places (OutParams always return full precision as specified in the DB schema)
assertEquals(0, cstmt.getObject(15, BigDecimal.class).compareTo(new BigDecimal("0.123456789")));
assertEquals(0,
cstmt.getObject("col15Value", BigDecimal.class).compareTo(new BigDecimal("0.1235")));
cstmt.getObject("col15Value", BigDecimal.class).compareTo(new BigDecimal("0.123456789")));

assertEquals(0, cstmt.getObject(16, BigDecimal.class).compareTo(new BigDecimal("0.1235")));
assertEquals(0, cstmt.getObject(16, BigDecimal.class).compareTo(new BigDecimal("0.1234567890123456789012345678901234567")));
assertEquals(0,
cstmt.getObject("col16Value", BigDecimal.class).compareTo(new BigDecimal("0.1235")));
cstmt.getObject("col16Value", BigDecimal.class).compareTo(new BigDecimal("0.1234567890123456789012345678901234567")));
}
}
}
Expand Down
Loading