You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Dave Dombrosky (JIRA)" <de...@cayenne.apache.org> on 2008/05/08 17:32:53 UTC

[jira] Created: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
-----------------------------------------------------------------

                 Key: CAY-1052
                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
             Project: Cayenne
          Issue Type: Bug
          Components: Cayenne Core Library
    Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
         Environment: All
            Reporter: Dave Dombrosky
            Assignee: Andrus Adamchik


A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.

In the TypesMapping class, there is the following code:

if (type == Types.NUMERIC && precision == 0) {
    type = Types.INTEGER;
}

This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
     [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik updated CAY-1052:
---------------------------------

    Affects Version/s:     (was: 3.0)

Just realized that this is another consequence of CAY-672 issue that has been fixed in 3.0 for some time. It still remains an issue in 2.0 and 1.2. Let me apply the fix to those.

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE]
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12849#action_12849 ] 

Andrus Adamchik commented on CAY-1052:
--------------------------------------

BTW, a very strange motivation for breaking a JDBC driver behavior ("0" scale means "zero digits to the right of the dot" to any sane person, not "undefined") because of  downstream "ORM tools". 

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE]
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Dave Dombrosky (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846#action_12846 ] 

Dave Dombrosky commented on CAY-1052:
-------------------------------------

Sorry, I forgot to mention that I tested this with the JDBC 3 drivers, which don't require Java 6.  I would assume the JDBC 4 jars would have the same behavior though.

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844#action_12844 ] 

Andrus Adamchik commented on CAY-1052:
--------------------------------------

Testing that required Java 6... Can't install it on a Mac just yet... Hopefully will have it in a few weeks.

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
     [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik closed CAY-1052.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0 [STABLE]
                   1.2 [STABLE]

Fixed for 1.2 and 2.0... It was working in 3.0 already

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE]
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>             Fix For: 1.2 [STABLE], 2.0 [STABLE]
>
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAY-1052) Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+

Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
    [ https://issues.apache.org/cayenne/browse/CAY-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12847#action_12847 ] 

Andrus Adamchik commented on CAY-1052:
--------------------------------------

ah cool. not sure why I thought that JDBC4 was involved.

> Invalid cast on NUMERICs with scale of 0 using Postgres JDBC 8.2+
> -----------------------------------------------------------------
>
>                 Key: CAY-1052
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1052
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
>         Environment: All
>            Reporter: Dave Dombrosky
>            Assignee: Andrus Adamchik
>
> A change was recently made in the Postgres JDBC driver, versions 8.2 and up, that makes some of the Cayenne code do the wrong thing now.
> In the TypesMapping class, there is the following code:
> if (type == Types.NUMERIC && precision == 0) {
>     type = Types.INTEGER;
> }
> This code no longer works right on the newer drivers because the behavior of the ResultSetMetaData.getScale() method was changed.  It used to return "-1" for NUMERICs where it could not determine the scale, but now it returns "0".  So values with decimal information are being truncated to integers.  Please reference the following thread for more detail on the return value change: http://groups.google.com/group/pgsql.interfaces.jdbc/browse_thread/thread/ee82d41155147672

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.