You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/09/25 07:02:14 UTC

[GitHub] [shardingsphere] xbkaishui opened a new pull request #7601: Support more java types for getObject

xbkaishui opened a new pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601


   Fixes #6209 
   
   Changes proposed in this pull request:
   - Support getURL
   - Support getBigDecimal
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r495554445



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {
+            throw new ShardingSphereException("Unsupported Date type: URL");
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {
+                // try this if above fails

Review comment:
       this is reference mysql  driver source code




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 merged pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
tuohai666 merged pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-699621699


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=h1) Report
   > Merging [#7601](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=desc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/ad535a1e0e349dd2174157addb2a171e4ce52eb5?el=desc) will **increase** coverage by `0.09%`.
   > The diff coverage is `96.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/7601/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7601      +/-   ##
   ============================================
   + Coverage     75.48%   75.57%   +0.09%     
   - Complexity      505      510       +5     
   ============================================
     Files          1396     1398       +2     
     Lines         22178    22233      +55     
     Branches       3948     3956       +8     
   ============================================
   + Hits          16741    16803      +62     
   + Misses         4376     4367       -9     
   - Partials       1061     1063       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [.../AbstractUnsupportedDatabaseMetaDataResultSet.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL3Vuc3VwcG9ydGVkL0Fic3RyYWN0VW5zdXBwb3J0ZWREYXRhYmFzZU1ldGFEYXRhUmVzdWx0U2V0LmphdmE=) | `92.30% <ø> (-1.45%)` | `1.00 <0.00> (ø)` | |
   | [...here/driver/jdbc/core/resultset/ResultSetUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvcmVzdWx0c2V0L1Jlc3VsdFNldFV0aWwuamF2YQ==) | `83.75% <94.73%> (+3.42%)` | `0.00 <0.00> (ø)` | |
   | [...jdbc/core/resultset/DatabaseMetaDataResultSet.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvcmVzdWx0c2V0L0RhdGFiYXNlTWV0YURhdGFSZXN1bHRTZXQuamF2YQ==) | `97.91% <100.00%> (+0.17%)` | `1.00 <0.00> (ø)` | |
   | [...ardingsphere/infra/route/context/RouteContext.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL3JvdXRlL2NvbnRleHQvUm91dGVDb250ZXh0LmphdmE=) | `88.88% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...te/decorator/UnconfiguredSchemaRouteDecorator.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL3JvdXRlL2RlY29yYXRvci9VbmNvbmZpZ3VyZWRTY2hlbWFSb3V0ZURlY29yYXRvci5qYXZh) | `42.85% <0.00%> (ø)` | `1.00% <0.00%> (ø%)` | |
   | [.../sql/parser/binder/SQLStatementContextFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWJpbmRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9iaW5kZXIvU1FMU3RhdGVtZW50Q29udGV4dEZhY3RvcnkuamF2YQ==) | `11.76% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...inder/statement/ddl/DropIndexStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWJpbmRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9iaW5kZXIvc3RhdGVtZW50L2RkbC9Ecm9wSW5kZXhTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...nder/statement/ddl/AlterIndexStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWJpbmRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9iaW5kZXIvc3RhdGVtZW50L2RkbC9BbHRlckluZGV4U3RhdGVtZW50Q29udGV4dC5qYXZh) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...ute/engine/ConsensusReplicationRouteDecorator.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtY29uc2Vuc3VzLXJlcGxpY2F0aW9uL3NoYXJkaW5nc3BoZXJlLWNvbnNlbnN1cy1yZXBsaWNhdGlvbi1yb3V0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmVwbGljYXRpb24vY29uc2Vuc3VzL3JvdXRlL2VuZ2luZS9Db25zZW5zdXNSZXBsaWNhdGlvblJvdXRlRGVjb3JhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | [...ngine/PrimaryReplicaReplicationRouteDecorator.java](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcHJpbWFyeS1yZXBsaWNhLXJlcGxpY2F0aW9uL3NoYXJkaW5nc3BoZXJlLXByaW1hcnktcmVwbGljYS1yZXBsaWNhdGlvbi1yb3V0ZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcmVwbGljYXRpb24vcHJpbWFyeXJlcGxpY2Evcm91dGUvZW5naW5lL1ByaW1hcnlSZXBsaWNhUmVwbGljYXRpb25Sb3V0ZURlY29yYXRvci5qYXZh) | `95.23% <0.00%> (ø)` | `0.00% <0.00%> (ø%)` | |
   | ... and [15 more](https://codecov.io/gh/apache/shardingsphere/pull/7601/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=footer). Last update [ad535a1...89d1634](https://codecov.io/gh/apache/shardingsphere/pull/7601?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
kimmking commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r495533002



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {
+            throw new ShardingSphereException("Unsupported Date type: URL");

Review comment:
       add parameter to message

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {
+            throw new ShardingSphereException("Unsupported Date type: URL");
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {
+                // try this if above fails

Review comment:
       no need to round

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {

Review comment:
       use ex




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-699580480


   Hi @xbkaishui So active these days. 👍 
   I suppose @tuohai666 is a good selection for reviewing.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
kimmking commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r497248186



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,48 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (final MalformedURLException ex) {
+            throw new ShardingSphereException("Unsupported Date type: URL value %s", value);

Review comment:
       should be val instead of value.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls commented on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-698815017


   ## Pull Request Test Coverage Report for [Build 15065](https://coveralls.io/builds/33717064)
   
   * **30** of **30**   **(100.0%)**  changed or added relevant lines in **2** files are covered.
   * **3** unchanged lines in **1** file lost coverage.
   * Overall coverage increased (+**0.02%**) to **35.126%**
   
   ---
   
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/RuleSchemaMetaData.java](https://coveralls.io/builds/33717064/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Fschema%2FRuleSchemaMetaData.java#L69) | 3 | 76.92% |
   <!-- | **Total:** | **3** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33717064/badge)](https://coveralls.io/builds/33717064) |
   | :-- | --: |
   | Change from base [Build 15057](https://coveralls.io/builds/33715202): |  0.02% |
   | Covered Lines: | 36648 |
   | Relevant Lines: | 104332 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls commented on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-698815017


   ## Pull Request Test Coverage Report for [Build 15065](https://coveralls.io/builds/33717064)
   
   * **30** of **30**   **(100.0%)**  changed or added relevant lines in **2** files are covered.
   * **3** unchanged lines in **1** file lost coverage.
   * Overall coverage increased (+**0.02%**) to **35.126%**
   
   ---
   
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/RuleSchemaMetaData.java](https://coveralls.io/builds/33717064/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Fschema%2FRuleSchemaMetaData.java#L69) | 3 | 76.92% |
   <!-- | **Total:** | **3** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33717064/badge)](https://coveralls.io/builds/33717064) |
   | :-- | --: |
   | Change from base [Build 15057](https://coveralls.io/builds/33715202): |  0.02% |
   | Covered Lines: | 36648 |
   | Relevant Lines: | 104332 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r495555169



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {
+            throw new ShardingSphereException("Unsupported Date type: URL");

Review comment:
       done

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException mfe) {

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-698815017


   ## Pull Request Test Coverage Report for [Build 15102](https://coveralls.io/builds/33749078)
   
   * **30** of **30**   **(100.0%)**  changed or added relevant lines in **2** files are covered.
   * **46** unchanged lines in **11** files lost coverage.
   * Overall coverage increased (+**0.04%**) to **35.149%**
   
   ---
   
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-features/shardingsphere-consensus-replication/shardingsphere-consensus-replication-route/src/main/java/org/apache/shardingsphere/replication/consensus/route/engine/ConsensusReplicationRouteDecorator.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-features%2Fshardingsphere-consensus-replication%2Fshardingsphere-consensus-replication-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Freplication%2Fconsensus%2Froute%2Fengine%2FConsensusReplicationRouteDecorator.java#L66) | 1 | 0% |
   | [shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-route/src/main/java/org/apache/shardingsphere/shadow/route/engine/ShadowRouteDecorator.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-features%2Fshardingsphere-shadow%2Fshardingsphere-shadow-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fshadow%2Froute%2Fengine%2FShadowRouteDecorator.java#L109) | 1 | 97.83% |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/refresh/impl/DropIndexStatementMetaDataRefreshStrategy.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Frefresh%2Fimpl%2FDropIndexStatementMetaDataRefreshStrategy.java#L56) | 1 | 93.33% |
   | [shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/context/RouteContext.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-infra%2Fshardingsphere-infra-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Froute%2Fcontext%2FRouteContext.java#L65) | 1 | 88.89% |
   | [shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/decorator/UnconfiguredSchemaRouteDecorator.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-infra%2Fshardingsphere-infra-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Froute%2Fdecorator%2FUnconfiguredSchemaRouteDecorator.java#L42) | 1 | 57.14% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterIndexStatement.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fcommon%2Fstatement%2Fddl%2FAlterIndexStatement.java#L42) | 1 | 50.0% |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingRouteDecorator.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2FShardingRouteDecorator.java#L90) | 2 | 96.88% |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/RuleSchemaMetaData.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Fschema%2FRuleSchemaMetaData.java#L69) | 3 | 76.92% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/ddl/AlterIndexStatementContext.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-binder%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fbinder%2Fstatement%2Fddl%2FAlterIndexStatementContext.java#L44) | 6 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/ddl/DropIndexStatementContext.java](https://coveralls.io/builds/33749078/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-binder%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fbinder%2Fstatement%2Fddl%2FDropIndexStatementContext.java#L44) | 6 | 0% |
   <!-- | **Total:** | **46** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33749078/badge)](https://coveralls.io/builds/33749078) |
   | :-- | --: |
   | Change from base [Build 15057](https://coveralls.io/builds/33715202): |  0.04% |
   | Covered Lines: | 36680 |
   | Relevant Lines: | 104357 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r497181358



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException ex) {
+            throw new ShardingSphereException("Unsupported Date type: URL value %s", value);
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {

Review comment:
       done

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException ex) {
+            throw new ShardingSphereException("Unsupported Date type: URL value %s", value);
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {
+                // try this if above fails

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on a change in pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on a change in pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#discussion_r496621178



##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException ex) {
+            throw new ShardingSphereException("Unsupported Date type: URL value %s", value);
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {

Review comment:
       final

##########
File path: shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtil.java
##########
@@ -77,6 +82,49 @@ public static Object convertValue(final Object value, final Class<?> convertType
             return value;
         }
     }
+    
+    private static Object convertURL(final Object value) {
+        String val = value.toString();
+        try {
+            return new URL(val);
+        } catch (MalformedURLException ex) {
+            throw new ShardingSphereException("Unsupported Date type: URL value %s", value);
+        }
+    }
+    
+    /**
+     * Convert object to BigDecimal.
+     *
+     * @param value current db object
+     * @param needScale need scale
+     * @param scale scale size
+     * @return big decimal
+     */
+    public static Object convertBigDecimalValue(final Object value, final boolean needScale, final int scale) {
+        if (null == value) {
+            return convertNullValue(BigDecimal.class);
+        }
+        if (value.getClass() == BigDecimal.class) {
+            return adjustBigDecimalResult((BigDecimal) value, needScale, scale);
+        }
+        if (value instanceof Number || value instanceof String) {
+            BigDecimal bigDecimal = new BigDecimal(value.toString());
+            return adjustBigDecimalResult(bigDecimal, needScale, scale);
+        }
+        throw new ShardingSphereException("Unsupported Date type: BigDecimal value %s", value);
+    }
+  
+    private static BigDecimal adjustBigDecimalResult(final BigDecimal value, final boolean needScale, final int scale) {
+        if (needScale) {
+            try {
+                return value.setScale(scale);
+            } catch (ArithmeticException ex) {
+                // try this if above fails

Review comment:
       remove comment




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7601: Support more java types for getObject

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7601:
URL: https://github.com/apache/shardingsphere/pull/7601#issuecomment-698815017


   ## Pull Request Test Coverage Report for [Build 15169](https://coveralls.io/builds/33804586)
   
   * **30** of **30**   **(100.0%)**  changed or added relevant lines in **2** files are covered.
   * **9431** unchanged lines in **35** files lost coverage.
   * Overall coverage increased (+**0.2%**) to **35.281%**
   
   ---
   
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/complex/ShardingCartesianRoutingEngine.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Ftype%2Fcomplex%2FShardingCartesianRoutingEngine.java#L106) | 1 | 97.73% |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngine.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2Ftype%2Funicast%2FShardingUnicastRoutingEngine.java#L89) | 1 | 97.56% |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/refresh/impl/CreateTableStatementMetaDataRefreshStrategy.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Frefresh%2Fimpl%2FCreateTableStatementMetaDataRefreshStrategy.java#L63) | 1 | 94.44% |
   | [shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/refresh/impl/DropIndexStatementMetaDataRefreshStrategy.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-infra%2Fshardingsphere-infra-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fmetadata%2Frefresh%2Fimpl%2FDropIndexStatementMetaDataRefreshStrategy.java#L56) | 1 | 93.33% |
   | [shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-infra%2Fshardingsphere-infra-executor%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Fexecutor%2Fsql%2Fcontext%2FExecutionContextBuilder.java#L99) | 1 | 96.97% |
   | [shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/decorator/UnconfiguredSchemaRouteDecorator.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-infra%2Fshardingsphere-infra-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Finfra%2Froute%2Fdecorator%2FUnconfiguredSchemaRouteDecorator.java#L46) | 1 | 57.14% |
   | [shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLErrPacketFactory.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-proxy%2Fshardingsphere-proxy-frontend%2Fshardingsphere-proxy-frontend-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fproxy%2Ffrontend%2Fmysql%2FMySQLErrPacketFactory.java#L95) | 1 | 96.67% |
   | [shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/RuleConfiguration.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-scaling%2Fshardingsphere-scaling-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fscaling%2Fcore%2Fconfig%2FRuleConfiguration.java#L56) | 1 | 85.71% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterIndexStatement.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fcommon%2Fstatement%2Fddl%2FAlterIndexStatement.java#L42) | 1 | 50.0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/dml/SQLServerInsertStatement.java](https://coveralls.io/builds/33804586/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fdialect%2Fstatement%2Fsqlserver%2Fdml%2FSQLServerInsertStatement.java#L55) | 1 | 66.67% |
   <!-- | **Total:** | **9431** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33804586/badge)](https://coveralls.io/builds/33804586) |
   | :-- | --: |
   | Change from base [Build 15057](https://coveralls.io/builds/33715202): |  0.2% |
   | Covered Lines: | 36834 |
   | Relevant Lines: | 104403 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org