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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---