[
https://issues.apache.org/jira/browse/METAMODEL-198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14962275#comment-14962275
]
ASF GitHub Bot commented on METAMODEL-198:
------------------------------------------
Github user ankit2711 commented on a diff in the pull request:
https://github.com/apache/metamodel/pull/58#discussion_r42319638
--- 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 --
Done.
> 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)