[ 
https://issues.apache.org/jira/browse/OPENJPA-2966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110771#comment-18110771
 ] 

ASF subversion and git services commented on OPENJPA-2966:
----------------------------------------------------------

Commit e2515a1d2105a9f298a34ac6a9a06e503e956057 in openjpa's branch 
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=e2515a1d2 ]

[OPENJPA-2966] Use a dedicated cast target type for long values (#157)

* [OPENJPA-2966] Use a dedicated cast target type for long values

Long values are now cast via a lazily resolved longCastTypeName (SIGNED on
MySQL/MariaDB) instead of the DDL decimalTypeName, which defaults to
DECIMAL(10,0) there and silently truncates, and both cast paths now strip the
size suffix through the same DBDictionary helpers.

* [OPENJPA-2966] integerCastTypeName is lazily calculated

* [OPENJPA-2966] Cache resolved CAST target type names

getNumberCastTypeName() and getStringCastTypeName() are called on every
SQL generation and stripped the DDL size marker each time. Cache the
stripped names, keyed by the DDL type name they were derived from, so a
dictionary that assigns its type names in the constructor or in
connectedConfiguration() still resolves correctly.

---------

Co-authored-by: Maxim Solodovnik <[email protected]>

> Long cast uses decimalTypeName instead of bigint
> ------------------------------------------------
>
>                 Key: OPENJPA-2966
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2966
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683002577
> **(medium)** Casting to Long uses {{dict.decimalTypeName}}; on MySQL {{CAST(x 
> AS DECIMAL)}} defaults to DECIMAL(10,0), so large long values 
> overflow/truncate - why not {{bigintTypeName}} for the long case? 
> Also {{getDbNumberTargetTypeName}} sanitizes the {{{0}}} size suffix while 
> the sibling {{TypecastAsString.java:152}} appends {{dict.varcharTypeName}} 
> raw - the two siblings should share the same sanitize logic.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to