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

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

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

[OPENJPA-2983] Resolve EXTRACT temporal fields by constant, not by name (#166)

CriteriaBuilderImpl.extract() derived the DateTimeExtractField from
field.toString().toUpperCase(), which depends on the default locale and on
the textual representation the specification constants happen to use. Map
the LocalDateField / LocalTimeField / LocalDateTimeField constants to their
DateTimeExtractField equivalents by identity instead, and reject any other
temporal field with a meaningful message instead of letting Enum.valueOf
fail.

TestExtractTemporalField pins every entry of the new mapping table, which
is where the risk now sits: it is a characterisation test of the 16 hand
written pairs, not a reproduction of the original defect, since the name
based lookup produced the same result for all constants once Locale.ROOT
was passed.

> Locale-sensitive toUpperCase on temporal field name
> ---------------------------------------------------
>
>                 Key: OPENJPA-2983
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2983
>             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_r3683005413
> **(low)** `field.toString().toUpperCase()` is locale-sensitive ("minute" 
> breaks under a Turkish default locale). Prefer `toUpperCase(Locale.ROOT)`, 
> and ideally key off the known LocalDateField/LocalTimeField constants rather 
> than `toString()`.



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

Reply via email to