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

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

Commit 9833103c9ea85722b06b83939c6ad9348f5aa0a6 in openjpa's branch 
refs/heads/OPENJPA-3063 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=9833103c9 ]

[OPENJPA-3063] Fix decimal columns, LOB types, CASE string results and EXTRACT 
parameters on HSQLDB

HSQLDictionary chose the HSQLDB 1.x column types VARCHAR and VARBINARY
for CLOB and BLOB while the database version was still unknown, so a
mapping resolved before the first connection got no LOB columns. Use
the 1.x types only once HSQLDB 1.x was detected.

HSQLDB 2.x reads an unsized NUMERIC or DECIMAL as NUMERIC(128,0) and
rounded fractional values to integers. Create an unsized decimal column
of a non integral Java type as NUMERIC(128,32), the size the dictionary
already uses for decimal casts, unless NumericTypeName, DecimalTypeName
or a column definition is set.

HSQLDB types a string literal as CHAR, so a CASE returning string
literals of different lengths padded the shorter results with spaces.
Add DBDictionary.requiresCastForCaseStringResult, which casts a string
literal, or a parameter bound to a string, returned by a CASE to
VARCHAR, and set it for HSQLDB.

HSQLDB rejects an untyped parameter in EXTRACT. Set
requiresCastForExtractOperand for HSQLDB and add
DBDictionary.getExtractOperandCastType, which HSQLDictionary overrides
to cast TIME and TIMESTAMP operands with nine fractional digits. Other
casts keep the plain types, so a compared parameter is still rounded to
the precision of the column. Bind and read a LocalTime with its
fractional seconds on HSQLDB 2.4 and later.


> HSQLDB: LOB type of converted attributes, decimal scale, CASE padding and 
> EXTRACT of a parameter fail
> -----------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3063
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3063
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> The test suite on HSQLDB ({{-Dtest-hsqldb}}) has 17 failures and 4 errors 
> (4022 tests), all from recent changes:
> * {{TestLobConverted}}, {{TestLobConvertedXml}} (OPENJPA-3020): a converted 
> attribute whose converter yields a String or byte[] gets a 
> {{VARCHAR}}/{{VARBINARY}} column instead of {{CLOB}}/{{BLOB}} 
> ({{expected:<2005> but was:<12>}}, {{expected:<2004> but was:<-3>}}).
> * {{TestDecimalScale}}, {{TestUnarySign}}, {{TestArithmeticResultType}}: 
> decimal values are stored rounded to integers ({{25.5 <> 25}}, {{1234.5678 <> 
> 1235}}). Same cause as OPENJPA-3051 (H2) and OPENJPA-3062 (MySQL, MariaDB): a 
> decimal column without a precision has scale 0.
> * {{TestSelectionParameters.testParameterInCaseOfSelect}} (OPENJPA-3040): 
> {{expected:<[young, old]> but was:<[young, old  ]>}}, the CASE result is 
> padded to the length of the longest branch.
> * {{TestEJBQLFunction.testExtractSecondKeepsFractionFromTime/Timestamp}}, 
> {{TestExtractDateTimeField.testExtractFromParameter/testCriteriaExtractFromLiteral}}:
>  {{EXTRACT(... FROM ?)}} fails with "data type cast needed for parameter or 
> null literal" ({{code=-5567, state=42567}}).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to