Author: shawkins
Date: 2010-10-25 12:31:58 -0400 (Mon, 25 Oct 2010)
New Revision: 2678
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
Log:
TEIID-1320 update to the oracle timestamp to string logic
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
---
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-10-22
21:42:45 UTC (rev 2677)
+++
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-10-25
16:31:58 UTC (rev 2678)
@@ -150,11 +150,9 @@
//if column and type is date, just use date format
Expression ex = function.getParameters().get(0);
String format = TIMESTAMP_FORMAT;
- if (ex instanceof ColumnReference) {
- if
("date".equals(((ColumnReference)ex).getMetadataObject().getNativeType())) {
//$NON-NLS-1$
- format = DATETIME_FORMAT;
- }
- } else if (!(ex instanceof Function) && !(ex instanceof Literal)) {
+ if (ex instanceof ColumnReference &&
"date".equalsIgnoreCase(((ColumnReference)ex).getMetadataObject().getNativeType()))
{ //$NON-NLS-1$
+ format = DATETIME_FORMAT;
+ } else if (!(ex instanceof Literal) && !(ex instanceof Function)) {
//this isn't needed in every case, but it's simpler than inspecting the
expression more
ex = ConvertModifier.createConvertFunction(getLanguageFactory(),
function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP);
}
Modified:
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
---
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-22
21:42:45 UTC (rev 2677)
+++
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-25
16:31:58 UTC (rev 2678)
@@ -34,6 +34,7 @@
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
+import org.teiid.metadata.Column;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.SQLConversionVisitor;
@@ -41,6 +42,7 @@
/**
*/
+@SuppressWarnings("nls")
public class TestOracleConvertModifier {
private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
@@ -500,6 +502,13 @@
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 10000000);
helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string",
"to_char({ts '2003-11-01 12:05:02.01'}, 'YYYY-MM-DD
HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ @Test public void testTimestampToString1() throws Exception {
+ Column column = new Column();
+ column.setNativeType("DATE");
+ column.setNameInSource("dt");
+ helpTest(LANG_FACTORY.createColumnReference("dt",
LANG_FACTORY.createNamedTable("x", null, null), column, Timestamp.class),
"string", "to_char(x.dt, 'YYYY-MM-DD HH24:MI:SS')");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
@Test public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 10000000);
Show replies by date