This is an automated email from the ASF dual-hosted git repository.

mattyb149 pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new c203205b3b NIFI-11860 fixed bug in ResultSetRecordSet affecting 
decimalScale when resultSetScale was zero.
c203205b3b is described below

commit c203205b3b6ef88778b721f43b2ccc68fbafc9d9
Author: Tamas Neumer <tamas.neu...@posedio.com>
AuthorDate: Mon Jul 31 05:12:23 2023 +0200

    NIFI-11860 fixed bug in ResultSetRecordSet affecting decimalScale when 
resultSetScale was zero.
    
    Signed-off-by: Matt Burgess <mattyb...@apache.org>
---
 .../nifi/serialization/record/ResultSetRecordSet.java      |  2 +-
 .../nifi/serialization/record/ResultSetRecordSetTest.java  | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java
 
b/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java
index 84a7b4569a..3357b06a7f 100644
--- 
a/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java
+++ 
b/nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/ResultSetRecordSet.java
@@ -325,7 +325,7 @@ public class ResultSetRecordSet implements RecordSet, 
Closeable {
             decimalPrecision = resultSetPrecision;
             //For the float data type Oracle return decimalScale < 0 which 
cause is not expected to org.apache.avro.LogicalTypes
             //Hence falling back to default scale if decimalScale < 0
-            decimalScale = resultSetScale > 0 ? resultSetScale : defaultScale;
+            decimalScale = resultSetScale >= 0 ? resultSetScale : defaultScale;
         } else {
             // If not, use default precision.
             decimalPrecision = defaultPrecision;
diff --git 
a/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java
 
b/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java
index e9e5ec861b..b1c272cdf6 100644
--- 
a/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java
+++ 
b/nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/ResultSetRecordSetTest.java
@@ -130,6 +130,20 @@ public class ResultSetRecordSetTest {
         thenAllColumnDataTypesAreCorrect(COLUMNS, expectedSchema, 
actualSchema);
     }
 
+    @Test
+    public void testCreateSchemaWhenScaleIsNonDefault() throws SQLException {
+        // given
+        final RecordSchema recordSchema = givenRecordSchema(COLUMNS);
+        final RecordSchema expectedSchema = givenRecordSchema(COLUMNS);
+
+        // when
+        final ResultSetRecordSet testSubject = new 
ResultSetRecordSet(resultSet, recordSchema, 10, 2);
+        final RecordSchema actualSchema = testSubject.getSchema();
+
+        // then
+        thenAllColumnDataTypesAreCorrect(COLUMNS, expectedSchema, 
actualSchema);
+    }
+
     @Test
     public void testCreateSchemaWhenNoRecordSchema() throws SQLException {
         // given

Reply via email to