[OPENJPA-2966] Use a dedicated cast target type for long values - #157
Open
rzo1 wants to merge 2 commits into
Open
[OPENJPA-2966] Use a dedicated cast target type for long values#157rzo1 wants to merge 2 commits into
rzo1 wants to merge 2 commits into
Conversation
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.
Contributor
|
I'll try to carefully check this one tomorrow morning my time :) |
solomax
reviewed
Aug 23, 2026
| * Dictionaries which change {@link #integerTypeName} do <em>not</em> implicitly change this value. | ||
| * Set it explicitly if the DDL type name is not a valid CAST target. | ||
| */ | ||
| public String integerCastTypeName = integerTypeName; |
Contributor
There was a problem hiding this comment.
integerTypeName is redefined by some DBDictionaries in constructor (lot's of them actually)
So this one also need to be lazy inited
| } else { | ||
| name = doubleTypeName; | ||
| } | ||
| return insertSize(name, null); |
Contributor
There was a problem hiding this comment.
Maybe i worth to cache these values instead of calling insertSize(...) all the time it might be performance unwise ....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes OPENJPA-2966: casting to
longused the DDLdecimalTypeName, which isDECIMAL(10,0)on MySQL/MariaDB and silently clamps any value past ten billion. Long casts now go through a newlongCastTypeName, resolved lazily frombigintTypeName(so per-dictionary overrides assigned in constructors orconnectedConfiguration()are picked up) and set toSIGNEDinMySQLDictionaryandMariaDBDictionary; no DDL type name is touched, so schema generation is unchanged. The second half of the report is fixed too:TypecastAsNumberandTypecastAsStringnow share the size-suffix stripping viaDBDictionary, which changes exactly one dictionary's output (FoxPro no longer emits the literalCAST(x AS CHARACTER{0})).