metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (METAMODEL-198) Where clauses on timestamp loses the nanoseconds
Date Sun, 18 Oct 2015 08:11:05 GMT

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

ASF GitHub Bot commented on METAMODEL-198:
------------------------------------------

Github user kaspersorensen commented on a diff in the pull request:

    https://github.com/apache/metamodel/pull/58#discussion_r42318408
  
    --- Diff: jdbc/src/main/java/org/apache/metamodel/jdbc/dialects/DefaultQueryRewriter.java
---
    @@ -106,14 +107,22 @@ private boolean needsQuoting(String alias, String identifierQuoteString)
{
         public String rewriteFilterItem(FilterItem item) {
             Object operand = item.getOperand();
             if (operand != null) {
    +            final SelectItem selectItem = item.getSelectItem();
                 if (operand instanceof String) {
                     String str = (String) operand;
                     // escape single quotes
                     if (str.indexOf('\'') != -1) {
                         str = escapeQuotes(str);
    -                    FilterItem replacementFilterItem = new FilterItem(item.getSelectItem(),
item.getOperator(), str);
    +                    FilterItem replacementFilterItem = new FilterItem(selectItem, item.getOperator(),
str);
                         return super.rewriteFilterItem(replacementFilterItem);
                     }
    +            } else if (operand instanceof Timestamp) {
    +                final OperatorType operator = item.getOperator();
    +                StringBuilder sb = new StringBuilder();
    +                sb.append(selectItem.getSameQueryAlias(false));
    +                FilterItem.appendOperator(sb, operand, operator);
    +                sb.append("TIMESTAMP \'" + operand.toString() + "\'");
    --- End diff --
    
    Would probably be a good idea to make a protected method "rewriteTimestamp(Timestamp)"
so that we can easily overwrite just that in any deviating dialects.


> Where clauses on timestamp loses the nanoseconds
> ------------------------------------------------
>
>                 Key: METAMODEL-198
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-198
>             Project: Apache MetaModel
>          Issue Type: Bug
>            Reporter: Ankit Kumar
>
> Queries having where clause on timestamp column in databases loses the nanoseconds. 
> This is happening because the Timestamp values are converted to Date object using the
new Date(long timeInMilliseconds).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message