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

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

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

[OPENJPA-3064] Keep decimal fractions and fix EXTRACT(WEEK) and EXTRACT(SECOND) 
on SQL Server

SQL Server reads an unsized DECIMAL or NUMERIC as DECIMAL(18,0), and
SQLServerDictionary wrote no precision or scale for any decimal column,
so 2.5 was stored as 3. Keep the precision and scale of decimal columns,
and create a decimal column of a non integral Java type without a
precision as NUMERIC(38, scale), with scale 10 if the mapping gives none,
unless NumericTypeName or DecimalTypeName was configured or a
columnDefinition is used. Move the check for an unsized decimal column
from H2Dictionary to DBDictionary, as for MySQL and MariaDB.

Render EXTRACT(WEEK) as DATEPART(ISO_WEEK, x), the ISO-8601 week, and
add DATEPART(NANOSECOND, x) / 1000000000.0 to EXTRACT(SECOND) so that
the fraction of the second is kept.


> SQL Server: decimal scale, EXTRACT(SECOND/WEEK), current local time and 
> shared test tables fail
> -----------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3064
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3064
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> The test suite on Microsoft SQL Server ({{-Dtest-mssql-docker}}) has 13 
> failures and 13 errors (4022 tests):
> * {{TestDecimalScale}}, {{TestUnarySign}}, {{TestArithmeticResultType}}: 
> decimal values are stored rounded to integers ({{2.5 <> 3}}, {{-25.5 <> 
> -26}}). Same cause as OPENJPA-3051 (H2), OPENJPA-3062 (MySQL, MariaDB) and 
> OPENJPA-3063 (HSQLDB): a decimal column without a precision has scale 0 
> ({{DECIMAL}} is {{DECIMAL(18, 0)}} on SQL Server).
> * {{TestEJBQLFunction.testExtractSecondKeepsFractionFromTime/Timestamp}}: 
> {{EXTRACT(SECOND)}} drops the fraction ({{expected:<42.75> but was:<42.0>}}), 
> see OPENJPA-3055.
> * {{TestExtractDateTimeField.testExtractWeek}}: {{expected:<[1, 52]> but 
> was:<[1, 53]>}}, {{EXTRACT(WEEK)}} is not the ISO week, see OPENJPA-3037.
> * {{TestJava8TimeTypes.testGetCurrentLocalTime}} fails.
> * {{TestFlushModeAutoNavigation}}, {{TestTckFixes}}, 
> {{TestTreatJoinOnEmbeddable}}: setting up the schema fails with "The object 
> 'PK__TPRODUCT__...' is dependent on column 'id'" ({{ALTER TABLE TPRODUCT DROP 
> COLUMN id}}, {{ALTER TABLE FLUSH_ORDER DROP COLUMN ID}}, code 5074). Several 
> test entities map the same table names ({{TPRODUCT}}, {{FLUSH_ORDER}}) with 
> different columns, and the schema refresh tries to drop a primary key column.



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

Reply via email to