[teiid-commits] teiid SVN: r1294 - in trunk: common-core/src/main/java/com/metamatrix/common/types/basic and 30 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sun Aug 30 18:19:08 EDT 2009


Author: shawkins
Date: 2009-08-30 18:19:06 -0400 (Sun, 30 Aug 2009)
New Revision: 1294

Added:
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SubstringFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLocateFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/resources/PartsSupplierOracle.vdb
Removed:
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2ConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/ModFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseConvertModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BasicFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BindValueVisitor.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/DropFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ReplacementVisitor.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SubstringFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyConvertModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestDropFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLOCATEFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/util/
   trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
   trunk/test-integration/src/test/resources/PartsSupplierOracle.vdb
Modified:
   trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/basic/NumberToBooleanTransform.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
   trunk/connector-api/src/main/java/org/teiid/connector/api/TypeFacility.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/informix/InformixSQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/ConcatFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/Log10FunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSpatialFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerCapabilities.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseCapabilities.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/AliasModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/EscapeSyntaxModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ExtractFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/FunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/LocateFunctionModifier.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLog10FunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestSubstringFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java
   trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
   trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
   trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
Log:
TEIID-806 TEIID-794 TEIID-741 TEIID-486 TEIID-799 simplifying functionmodifier, combining the modfunctionmodifier impls, updating all convert modifiers to better represent teiid type handling (especially char and boolean)

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -579,7 +579,7 @@
 	static void loadBasicTransforms() {
 		DataTypeManager
 				.addTransform(new com.metamatrix.common.types.basic.BigDecimalToBigIntegerTransform());
-		DataTypeManager.addTransform(new NumberToBooleanTransform(BigDecimal.valueOf(1), BigDecimal.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(BigDecimal.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.BIG_DECIMAL));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
@@ -596,7 +596,7 @@
 		
 		DataTypeManager
 				.addTransform(new com.metamatrix.common.types.basic.BigIntegerToBigDecimalTransform());
-		DataTypeManager.addTransform(new NumberToBooleanTransform(BigInteger.valueOf(1), BigInteger.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(BigInteger.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.BIG_INTEGER));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
@@ -631,7 +631,7 @@
 
 		DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.BYTE));
 		DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.BYTE));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Byte.valueOf((byte)1), Byte.valueOf((byte)0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Byte.valueOf((byte)0)));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
 				DefaultDataClasses.BYTE, false));
 		DataTypeManager.addTransform(new NumberToFloatTransform(
@@ -655,7 +655,7 @@
 
 		DataTypeManager.addTransform(new FloatingNumberToBigDecimalTransform(DefaultDataClasses.DOUBLE));
 		DataTypeManager.addTransform(new FloatingNumberToBigIntegerTransform(DefaultDataClasses.DOUBLE));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Double.valueOf(1), Double.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Double.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.DOUBLE));
 		DataTypeManager.addTransform(new NumberToFloatTransform(
@@ -670,7 +670,7 @@
 
 		DataTypeManager.addTransform(new FloatingNumberToBigDecimalTransform(DefaultDataClasses.FLOAT));
 		DataTypeManager.addTransform(new FloatingNumberToBigIntegerTransform(DefaultDataClasses.FLOAT));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Float.valueOf(1), Float.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Float.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.FLOAT));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
@@ -685,7 +685,7 @@
 
 		DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.INTEGER));
 		DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.INTEGER));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Integer.valueOf(1), Integer.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Integer.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.INTEGER));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
@@ -700,7 +700,7 @@
 
 		DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.LONG));
 		DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.LONG));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Long.valueOf(1), Long.valueOf(0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Long.valueOf(0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.LONG));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(
@@ -715,7 +715,7 @@
 				
 		DataTypeManager.addTransform(new FixedNumberToBigDecimalTransform(DefaultDataClasses.SHORT));
 		DataTypeManager.addTransform(new FixedNumberToBigIntegerTransform(DefaultDataClasses.SHORT));
-		DataTypeManager.addTransform(new NumberToBooleanTransform(Short.valueOf((short)1), Short.valueOf((short)0)));
+		DataTypeManager.addTransform(new NumberToBooleanTransform(Short.valueOf((short)0)));
 		DataTypeManager.addTransform(new NumberToByteTransform(
 				DefaultDataClasses.SHORT));
 		DataTypeManager.addTransform(new NumberToDoubleTransform(

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/NumberToBooleanTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/NumberToBooleanTransform.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/NumberToBooleanTransform.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,28 +25,24 @@
 import com.metamatrix.common.types.AbstractTransform;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.ErrorMessageKeys;
 
 public class NumberToBooleanTransform extends AbstractTransform {
 	
-	private Object trueVal;
-	private Object falseVal;
+	private Comparable falseVal;
 	private Class<?> sourceType;
 	
-	public NumberToBooleanTransform(Object trueVal, Object falseVal) {
-		this.trueVal = trueVal;
+	public NumberToBooleanTransform(Comparable falseVal) {
 		this.falseVal = falseVal;
-		this.sourceType = trueVal.getClass();
+		this.sourceType = falseVal.getClass();
 	}
 
 	@Override
-	public Class getSourceType() {
+	public Class<?> getSourceType() {
 		return sourceType;
 	}
 	
 	@Override
-	public Class getTargetType() {
+	public Class<?> getTargetType() {
 		return DataTypeManager.DefaultDataClasses.BOOLEAN;
 	}
 	
@@ -55,13 +51,15 @@
 		if (value == null) {
 			return null;
 		}
-		if (value.equals(trueVal)) {
-			return Boolean.TRUE;
-		}
-		if (value.equals(falseVal)) {
+		if (falseVal.compareTo(value) == 0) {
 			return Boolean.FALSE;
 		}
-		throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0013, CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0013, sourceType.getSimpleName(), value));
+		return Boolean.TRUE;
 	}
+	
+	@Override
+	public boolean isNarrowing() {
+		return true;
+	}
 
 }

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -29,13 +29,10 @@
 import com.metamatrix.common.types.AbstractTransform;
 import com.metamatrix.common.types.TransformationException;
 import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.ErrorMessageKeys;
 
 public class StringToBooleanTransform extends AbstractTransform {
 
-    private static final Set<String> TRUE = new HashSet<String>(Arrays.asList("1", "TRUE")); //$NON-NLS-1$ //$NON-NLS-2$
-    private static final Set<String> FALSE = new HashSet<String>(Arrays.asList("0", "FALSE")); //$NON-NLS-1$ //$NON-NLS-2$
+    private static final Set<String> FALSE = new HashSet<String>(Arrays.asList("0", "false")); //$NON-NLS-1$ //$NON-NLS-2$
 
 	/**
 	 * This method transforms a value of the source type into a value
@@ -49,17 +46,14 @@
 		if(value == null) {
 			return value;
 		}
-		String str = ((String)value).trim().toUpperCase();
-        if (TRUE.contains(str)) {
-            return Boolean.TRUE;
-        }
+		String str = ((String)value).trim().toLowerCase();
         if (FALSE.contains(str)) {
             return Boolean.FALSE;
         }
-        if ("UNKNOWN".equals(str)) { //$NON-NLS-1$
+        if ("unknown".equals(str)) { //$NON-NLS-1$
         	return null;
         }
-		throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0013, CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0013, getSourceType().getSimpleName(), value));
+		return Boolean.TRUE;
 	}
 
 	/**
@@ -78,4 +72,9 @@
 		return DefaultDataClasses.BOOLEAN;
 	}
 	
+	@Override
+	public boolean isNarrowing() {
+		return true;
+	}
+	
 }

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -59,18 +59,15 @@
         try {                        
             Transform transform = DataTypeManager.getTransform(DataTypeManager.getDataTypeClass(src), expectedValue.getClass());
             Object result = transform.transform(value);
-            assertTrue(expectedValue.getClass().isAssignableFrom(result.getClass()));
+        	assertTrue(expectedValue.getClass().isAssignableFrom(result.getClass()));
         } catch (TransformationException e) {
             if (!isException(DataTypeManager.getDataTypeName(value.getClass()), target,value)) {
                 throw e;
-            }
+            } 
+            fail("Expected exception for " +src+ " to " + target); //$NON-NLS-1$ //$NON-NLS-2$            
         }
     }    
 
-    private static void helpTransformException(Object value, Class<?> target) {
-    	helpTransformException(value, target, null);
-    }
-    
     private static void helpTransformException(Object value, Class<?> target, String msg) {
         try {
             Transform transform = DataTypeManager.getTransform(value.getClass(), target);
@@ -92,39 +89,45 @@
         helpTestTransform(new String("0"), Boolean.FALSE); //$NON-NLS-1$
         helpTestTransform(new String("true"), Boolean.TRUE); //$NON-NLS-1$
         helpTestTransform(new String("false"), Boolean.FALSE); //$NON-NLS-1$
-        helpTransformException(new String("foo"), DataTypeManager.DefaultDataClasses.BOOLEAN); //$NON-NLS-1$
+        helpTestTransform(new String("foo"), Boolean.TRUE); //$NON-NLS-1$
     }
     
     @Test public void testByte2Boolean() throws TransformationException {
         helpTestTransform(new Byte((byte)1), Boolean.TRUE);
         helpTestTransform(new Byte((byte)0), Boolean.FALSE);
-        helpTransformException(new Byte((byte)12), DataTypeManager.DefaultDataClasses.BOOLEAN);
+        helpTestTransform(new Byte((byte)12), Boolean.TRUE);
     }
 
     @Test public void testShort2Boolean() throws TransformationException {
         helpTestTransform(new Short((short)1), Boolean.TRUE);
         helpTestTransform(new Short((short)0), Boolean.FALSE);
-        helpTransformException(new Short((short)12), DataTypeManager.DefaultDataClasses.BOOLEAN);
+        helpTestTransform(new Short((short)12), Boolean.TRUE);
     }
 
     @Test public void testInteger2Boolean() throws TransformationException {
         helpTestTransform(new Integer(1), Boolean.TRUE);
         helpTestTransform(new Integer(0), Boolean.FALSE);
-        helpTransformException(new Integer(12), DataTypeManager.DefaultDataClasses.BOOLEAN);
+        helpTestTransform(new Integer(12), Boolean.TRUE);
     }
 
     @Test public void testLong2Boolean() throws TransformationException {
         helpTestTransform(new Long(1), Boolean.TRUE);
         helpTestTransform(new Long(0), Boolean.FALSE);
-        helpTransformException(new Long(12), DataTypeManager.DefaultDataClasses.BOOLEAN);
+        helpTestTransform(new Long(12), Boolean.TRUE);
     }
     
     @Test public void testBigInteger2Boolean() throws TransformationException {
         helpTestTransform(new BigInteger("1"), Boolean.TRUE); //$NON-NLS-1$
         helpTestTransform(new BigInteger("0"), Boolean.FALSE); //$NON-NLS-1$
-        helpTransformException(new BigInteger("12"), DataTypeManager.DefaultDataClasses.BOOLEAN); //$NON-NLS-1$
+        helpTestTransform(new BigInteger("12"), Boolean.TRUE); //$NON-NLS-1$
     }
     
+    @Test public void testBigDecimal2Boolean() throws TransformationException {
+        helpTestTransform(new BigDecimal("1"), Boolean.TRUE); //$NON-NLS-1$
+        helpTestTransform(new BigDecimal("0"), Boolean.FALSE); //$NON-NLS-1$
+        helpTestTransform(new BigDecimal("0.00"), Boolean.FALSE); //$NON-NLS-1$
+    }
+    
     static Object[][] testData = {
         /*string-0*/  {"1", "0", "123"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         /*char-1*/    {new Character('1'), new Character('0'), new Character('1')},
@@ -149,20 +152,10 @@
     private String[] dataTypes = TestDataTypeManager.dataTypes;
     private char[][] conversions = TestDataTypeManager.conversions;
     private static boolean isException(String src, String tgt, Object source) {
-        return (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[0][2])
-            || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.XML))
-            || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.CHAR))  
+        return (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.XML))
             || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.TIME)) 
             || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.TIMESTAMP)) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.DATE)) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.BYTE) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[3][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.SHORT) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[4][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.INTEGER) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[5][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.LONG) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[6][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.BIG_INTEGER) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[7][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.FLOAT) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[8][2])         
-            || (src.equals(DataTypeManager.DefaultDataTypes.DOUBLE) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[9][2]) 
-            || (src.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL) && tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[10][2]);             
+            || (src.equals(DataTypeManager.DefaultDataTypes.STRING) && tgt.equals(DataTypeManager.DefaultDataTypes.DATE));             
     }
     
     @Test public void testAllConversions() throws TransformationException {

Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/TypeFacility.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/TypeFacility.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/TypeFacility.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -83,6 +83,13 @@
     }
     
     /**
+     * Get the String constant for the given type class
+     */
+    public static String getDataTypeName(Class<?> type) {
+    	return DataTypeManager.getDataTypeName(type);    	
+    }
+    
+    /**
      * Get the SQL type for the given runtime type Class constant
      * @param type
      * @return

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2ConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2ConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,337 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.db2;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-
-
-/**
- */
-public class DB2ConvertModifier extends BasicFunctionModifier {
-
-    private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
-
-    private ILanguageFactory langFactory;
-    
-    public DB2ConvertModifier(ILanguageFactory langFactory) {
-        this.langFactory = langFactory;
-    }
-
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        Class sourceType = args.get(0).getType();
-        String targetTypeString = getTargetType(args.get(1));
-        Class targetType = TypeFacility.getDataTypeClass(targetTypeString);
-        IExpression returnExpr = null;
-        
-        if(targetType != null) {
-        
-            // targetType is always lower-case due to getTargetType implementation
-            if(targetType.equals(TypeFacility.RUNTIME_TYPES.STRING)) { 
-                returnExpr = convertToString(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) { 
-                returnExpr = convertToTimestamp(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DATE)) { 
-                returnExpr = convertToDate(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIME)) { 
-                returnExpr = convertToTime(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN) || 
-                            targetType.equals(TypeFacility.RUNTIME_TYPES.BYTE) || 
-                            targetType.equals(TypeFacility.RUNTIME_TYPES.SHORT)) {  
-                returnExpr = convertToSmallInt(args.get(0), sourceType, targetType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.INTEGER)) {  
-                returnExpr = convertToInteger(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.LONG) || 
-                            targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_INTEGER)) {  
-                returnExpr = convertToBigInt(args.get(0), sourceType);
-                
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.FLOAT)) {  
-                returnExpr = convertToReal(args.get(0), sourceType);
-
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE)) {  
-                returnExpr = convertToDouble(args.get(0), sourceType);
-
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)) {  
-                returnExpr = convertToBigDecimal(args.get(0), sourceType);
-
-            } else if(targetType.equals(TypeFacility.RUNTIME_TYPES.CHAR)) { 
-                returnExpr = convertToChar(args.get(0), sourceType);
-            } 
-            
-            if(returnExpr != null) {
-                return returnExpr;
-            }
-        }
-        
-        // Last resort - just drop the convert and let the db figure it out
-        return DROP_MODIFIER.modify(function);  
-    }
-
-    /** 
-     * @param expression
-     * @return
-     * @since 4.2
-     */
-    private String getTargetType(IExpression expression) {
-        if(expression != null && expression instanceof ILiteral) {
-            String target = (String) ((ILiteral)expression).getValue();
-            return target.toLowerCase();
-        } 
-        
-        return null;            
-    }
-    
-
-    /** 
-     * @param expression
-     * @param sourceType
-     * @return
-     * @since 4.2
-     */
-    private IExpression convertToString(IExpression expression,
-                                        Class sourceType) {
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) {
-            // BEFORE: convert(booleanExpression, string)
-            // AFTER:  CASE WHEN booleanExpression = 0 THEN 'false' ELSE 'true' END
-
-            ILiteral literalZero = this.langFactory.createLiteral(new Integer(0), TypeFacility.RUNTIME_TYPES.INTEGER);
-            ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalZero);
-            List whens = new ArrayList(1);
-            whens.add(when);
-            
-            ILiteral literalFalse = this.langFactory.createLiteral("false", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
-            List thens = new ArrayList(1);
-            thens.add(literalFalse);
-            
-            ILiteral literalTrue = this.langFactory.createLiteral("true", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
-                        
-            return this.langFactory.createSearchedCaseExpression(whens, thens, literalTrue, TypeFacility.RUNTIME_TYPES.STRING);
-            
-        } else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.CHAR)) {
-            // Drop convert entirely for char
-            return null;
-            
-        } else {
-            // BEFORE: convert(EXPR, string) 
-            // AFTER:  char(EXPR) 
-            return wrapNewFunction(expression, "char", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$            
-        }
-    }
-    
-    private IExpression convertToChar(IExpression expression,
-                                        Class sourceType) {
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
-            ILiteral literalOne = this.langFactory.createLiteral(new Integer(1), TypeFacility.RUNTIME_TYPES.INTEGER);
-            return this.langFactory.createFunction("char", Arrays.asList(expression, literalOne), TypeFacility.RUNTIME_TYPES.CHAR); //$NON-NLS-1$
-        } 
-        
-        return null;
-    }
-
-    private IExpression convertToSmallInt(IExpression expression,
-                                        Class sourceType, Class targetType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING) && targetType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) { 
-            // BEFORE: convert(stringExpression, boolean)
-            // AFTER:  CASE WHEN stringExpression = 'true' THEN 1 ELSE 0 END
-            ILiteral literalTrue = this.langFactory.createLiteral("true", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
-            ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalTrue);
-            List whens = new ArrayList(1);
-            whens.add(when);
-            
-            ILiteral literalOne = this.langFactory.createLiteral(new Integer(1), TypeFacility.RUNTIME_TYPES.INTEGER);
-            List thens = new ArrayList(1);
-            thens.add(literalOne);
-            
-            ILiteral literalZero = this.langFactory.createLiteral(new Integer(0), TypeFacility.RUNTIME_TYPES.INTEGER);
-                                    
-            return this.langFactory.createSearchedCaseExpression(whens, thens, literalZero, TypeFacility.RUNTIME_TYPES.STRING);
-            
-        } else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.BYTE) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.SHORT)){
-            
-            // Just drop these
-            return null;
-        }
-
-        // BEFORE: convert(expression, [boolean,byte,short])
-        // AFTER:  smallint(expression)
-        return wrapNewFunction(expression, "smallint", targetType); //$NON-NLS-1$
-    }
-
-    private IExpression convertToInteger(IExpression expression, Class sourceType) {
-          
-          if(sourceType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN) || 
-                          sourceType.equals(TypeFacility.RUNTIME_TYPES.BYTE) || 
-                          sourceType.equals(TypeFacility.RUNTIME_TYPES.SHORT)){
-              
-              // Just drop these
-              return null;
-          } 
-
-          // BEFORE: convert(expression, integer)
-          // AFTER:  integer(expression)
-          return wrapNewFunction(expression, "integer", TypeFacility.RUNTIME_TYPES.INTEGER); //$NON-NLS-1$
-      }
-
-    private IExpression convertToBigInt(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING) ||
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.FLOAT) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)){
-
-            // BEFORE: convert(expression, [long, biginteger])
-            // AFTER:  bigint(expression)
-            return wrapNewFunction(expression, "bigint", TypeFacility.RUNTIME_TYPES.LONG); //$NON-NLS-1$
-
-        } 
-
-        // Just drop anything else
-        return null;
-    }
-
-    protected IExpression convertToReal(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING) ||
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)){
-
-            // BEFORE: convert(expression, [double, bigdecimal])
-            // AFTER:  real(expression)
-            return wrapNewFunction(expression, "real", TypeFacility.RUNTIME_TYPES.FLOAT); //$NON-NLS-1$
-
-        } 
-
-        // Just drop anything else
-        return null;
-    }
-
-    protected IExpression convertToDouble(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)){
-
-            // BEFORE: convert(expression, double)
-            // AFTER:  double(expression)
-            return wrapNewFunction(expression, "double", TypeFacility.RUNTIME_TYPES.DOUBLE); //$NON-NLS-1$
-
-        } 
-
-        // Just drop anything else
-        return null;
-    }
-
-    protected IExpression convertToBigDecimal(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)){
-
-            // BEFORE: convert(expression, bigdecimal)
-            // AFTER:  decimal(expression)
-            return wrapNewFunction(expression, "decimal", TypeFacility.RUNTIME_TYPES.BIG_DECIMAL); //$NON-NLS-1$
-
-        } 
-
-        // Just drop anything else
-        return null;
-    }
-
-    /** 
-     * @param expression
-     * @param sourceType
-     * @return
-     * @since 4.2
-     */
-    private IExpression convertToDate(IExpression expression,
-                                      Class sourceType) {
-                                
-        // BEFORE: convert(EXPR, date) 
-        // AFTER:  date(EXPR) 
-        return wrapNewFunction(expression, "date", TypeFacility.RUNTIME_TYPES.DATE); //$NON-NLS-1$
-    }
-
-    private IExpression convertToTime(IExpression expression, Class sourceType) {
-                                
-        // BEFORE: convert(EXPR, time) 
-        // AFTER:  time(EXPR) 
-        return wrapNewFunction(expression, "time", TypeFacility.RUNTIME_TYPES.DATE); //$NON-NLS-1$
-    }
-
-    private IExpression convertToTimestamp(IExpression expression,
-                                            Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
-            // BEFORE: convert(EXPR, timestamp)
-            // AFTER:  timestamp(expr)
-            return wrapNewFunction(expression, "timestamp", TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
-            
-        } else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
-            // BEFORE: convert(EXPR, timestamp)
-            // AFTER:  timestamp(EXPR, '00:00:00')
-            ILiteral timeString = this.langFactory.createLiteral("00:00:00", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
-            return this.langFactory.createFunction("timestamp", Arrays.asList(expression, timeString), TypeFacility.RUNTIME_TYPES.TIMESTAMP);             //$NON-NLS-1$
-            
-        } else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
-            // BEFORE: convert(EXPR, timestamp)
-            // AFTER:  timestamp('1970-01-01', EXPR)
-            ILiteral dateString = this.langFactory.createLiteral("1970-01-01", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
-            return this.langFactory.createFunction("timestamp", Arrays.asList(dateString, expression), TypeFacility.RUNTIME_TYPES.TIMESTAMP);             //$NON-NLS-1$
-        }
-        
-        return null;
-    }
-    
-    /** 
-     * @param expression
-     * @param functionName
-     * @param outputType
-     * @return
-     * @since 4.2
-     */
-    private IFunction wrapNewFunction(IExpression expression,
-                                      String functionName,
-                                      Class outputType) {
-        return langFactory.createFunction(functionName, 
-            Arrays.asList(expression),
-            outputType);
-    }
-
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/db2/DB2SQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -22,7 +22,6 @@
 
 package org.teiid.connector.jdbc.db2;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -32,41 +31,89 @@
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.api.TypeFacility.RUNTIME_TYPES;
 import org.teiid.connector.jdbc.translator.AliasModifier;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.jdbc.translator.LocateFunctionModifier;
 import org.teiid.connector.jdbc.translator.ModFunctionModifier;
 import org.teiid.connector.jdbc.translator.Translator;
-import org.teiid.connector.language.ICommand;
 import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.IJoin;
+import org.teiid.connector.language.ILanguageObject;
 import org.teiid.connector.language.ILimit;
 import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.IQuery;
-import org.teiid.connector.language.ISelect;
 import org.teiid.connector.language.ISelectSymbol;
 import org.teiid.connector.language.ICompareCriteria.Operator;
 import org.teiid.connector.language.IJoin.JoinType;
-import org.teiid.connector.visitor.framework.HierarchyVisitor;
-
 
 public class DB2SQLTranslator extends Translator {
 
+	private final class NullHandlingFormatModifier extends
+			ConvertModifier.FormatModifier {
+		private NullHandlingFormatModifier(String alias) {
+			super(alias);
+		}
+
+		@Override
+		public List<?> translate(IFunction function) {
+			IExpression arg = function.getParameters().get(0);
+			if (arg instanceof ILiteral && ((ILiteral)arg).getValue() == null) {
+				((ILiteral)function.getParameters().get(1)).setValue(this.alias);
+				return null;
+			}
+			return super.translate(function);
+		}
+	}
+
 	@Override
 	public void initialize(ConnectorEnvironment env) throws ConnectorException {
 		super.initialize(env);
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new DB2ConvertModifier(getLanguageFactory())); 
         registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
         registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$ 
 
-        List<Class<?>> supportedModTypes = new ArrayList<Class<?>>(3);
-        supportedModTypes.add(RUNTIME_TYPES.SHORT);
-        supportedModTypes.add(RUNTIME_TYPES.INTEGER);
-        supportedModTypes.add(RUNTIME_TYPES.LONG);
-        registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory(), "MOD", supportedModTypes));  //$NON-NLS-1$
+        registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("MOD", getLanguageFactory()));  //$NON-NLS-1$
+        
+        //add in type conversion
+        ConvertModifier convertModifier = new ConvertModifier();
+    	convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(31,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(31,12)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("blob", FunctionModifier.BLOB, FunctionModifier.OBJECT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("clob", FunctionModifier.CLOB, FunctionModifier.XML); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList("timestamp('1970-01-01', ", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList("timestamp(",function.getParameters().get(0), ", '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
+    	//the next convert is not strictly necessary for db2, but it also works for derby
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList("cast(double(", function.getParameters().get(0), ") as real)"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("char"), FunctionModifier.STRING); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("smallint"), FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("integer"), FunctionModifier.INTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("bigint"), FunctionModifier.LONG); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("double"), FunctionModifier.DOUBLE); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("date"), FunctionModifier.DATE); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("time"), FunctionModifier.TIME); //$NON-NLS-1$
+    	convertModifier.addTypeConversion(new NullHandlingFormatModifier("timestamp"), FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+    	convertModifier.addNumericBooleanConversions();
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
     }
 		
 	@SuppressWarnings("unchecked")
@@ -76,33 +123,27 @@
 	}
 	
 	@Override
-	public ICommand modifyCommand(ICommand command, ExecutionContext context) {
-		if (command instanceof IQuery) {
-			HierarchyVisitor hierarchyVisitor = new HierarchyVisitor(false) {
-				@Override
-				public void visit(IJoin obj) {
-					if (obj.getJoinType() != JoinType.CROSS_JOIN) {
-						return;
-					}
-					ILiteral one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
-					obj.getCriteria().add(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one));
-					obj.setJoinType(JoinType.INNER_JOIN);
+	public List<?> translate(ILanguageObject obj, ExecutionContext context) {
+		//DB2 doesn't support cross join
+		if (obj instanceof IJoin) {
+			IJoin join = (IJoin)obj;
+			if (join.getJoinType() == JoinType.CROSS_JOIN) {
+				ILiteral one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
+				join.getCriteria().add(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one));
+				join.setJoinType(JoinType.INNER_JOIN);
+			}
+		}
+		//DB2 needs projected nulls wrapped in casts
+		if (obj instanceof ISelectSymbol) {
+			ISelectSymbol selectSymbol = (ISelectSymbol)obj;
+			if (selectSymbol.getExpression() instanceof ILiteral) {
+				ILiteral literal = (ILiteral)selectSymbol.getExpression();
+				if (literal.getValue() == null) {
+					selectSymbol.setExpression(ConvertModifier.createConvertFunction(getLanguageFactory(), literal, TypeFacility.getDataTypeName(literal.getType())));
 				}
-			};
-			
-			command.acceptVisitor(hierarchyVisitor);
-			
-			ISelect select = ((IQuery)command).getSelect();
-			for (ISelectSymbol selectSymbol : select.getSelectSymbols()) {
-				if (selectSymbol.getExpression() instanceof ILiteral) {
-					ILiteral literal = (ILiteral)selectSymbol.getExpression();
-					if (literal.getValue() == null) {
-						selectSymbol.setExpression(createCastToExprType(literal));
-					}
-				}
 			}
 		}
-		return command;
+		return super.translate(obj, context);
 	}
 	
 	@Override
@@ -115,67 +156,6 @@
 		return DB2Capabilities.class;
 	}
     
-	/**
-	 * Create and return an expression to cast <code>expr</code> to <code>expr</code>'s
-	 * type.
-	 * <p>  
-	 * If a compatible type is not found, <code>expr</code> is returned unmodified.
-	 * <p>
-	 * <em>WARNING</em>: This method currently returns the smallest type associated with 
-	 * the run-time type. So, all <code>String</code> expressions, regardless of
-	 * their value's length are returned as CHAR.
-	 * <p>
-	 * For example, if <code>expr</code> is "e1" of type <code>String</code> the 
-	 * returned expression would be "CAST(expr AS CHAR)".
-	 *  
-	 * @param expr
-	 * @return
-	 */
-	private IExpression createCastToExprType(IExpression expr) {
-		String typeName = null;
-		if ( RUNTIME_TYPES.STRING.equals(expr.getType()) ) {
-			typeName = "CHAR"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.BOOLEAN.equals(expr.getType()) ) {
-			typeName = "SMALLINT"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.BYTE.equals(expr.getType()) ) {
-			typeName = "SMALLINT"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.SHORT.equals(expr.getType()) ) {
-			typeName = "SMALLINT"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.CHAR.equals(expr.getType()) ) {
-			typeName = "CHAR"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.INTEGER.equals(expr.getType()) ) {
-			typeName = "INTEGER"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.LONG.equals(expr.getType()) ) {
-			typeName = "BIGINT"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.BIG_INTEGER.equals(expr.getType()) ) {
-			typeName = "BIGINT"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.FLOAT.equals(expr.getType()) ) {
-			typeName = "REAL"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.DOUBLE.equals(expr.getType()) ) {
-			typeName = "DOUBLE"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.BIG_DECIMAL.equals(expr.getType()) ) {
-			typeName = "DECIMAL"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.DATE.equals(expr.getType()) ) {
-			typeName = "DATE"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.TIME.equals(expr.getType()) ) {
-			typeName = "TIME"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.TIMESTAMP.equals(expr.getType()) ) {
-			typeName = "TIMESTAMP"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.OBJECT.equals(expr.getType()) ) {
-			typeName = "BLOB"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.BLOB.equals(expr.getType()) ) {
-			typeName = "BLOB"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.CLOB.equals(expr.getType()) ) {
-			typeName = "CLOB"; //$NON-NLS-1$
-		} else if ( RUNTIME_TYPES.XML.equals(expr.getType()) ) {
-			typeName = "CLOB"; //$NON-NLS-1$
-		}	
-		if ( typeName != null ) {
-			return getLanguageFactory().createFunction("CAST", Arrays.asList(expr, getLanguageFactory().createLiteral(typeName, String.class)), expr.getType()); //$NON-NLS-1$
-		}
-		return expr;
-	}
-
 	@Override
 	public NullOrder getDefaultNullOrder() {
 		return NullOrder.HIGH;

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbyConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.derby;
-
-import java.util.Arrays;
-
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.db2.DB2ConvertModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-
-/**
- */
-public class DerbyConvertModifier extends DB2ConvertModifier {
-
-    private ILanguageFactory langFactory;
-    
-    public DerbyConvertModifier(ILanguageFactory langFactory) {
-    	super(langFactory);
-        this.langFactory = langFactory;
-    }
-    
-    @Override
-    protected IExpression convertToReal(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)){
-
-            // BEFORE: convert(string_expr, float)
-            // AFTER:  cast(cast(string_expr as decimal) as float)
-            IFunction inner = langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
-
-            IFunction outer = langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( inner, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.FLOAT);
-
-            return outer; 
-
-        } else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE) || 
-                        sourceType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)) {
-        
-            // BEFORE: convert(num_expr, float)
-            // AFTER:  cast(num_expr as float)
-            return langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( expression, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.FLOAT);
-        }
-
-        // Just drop anything else
-        return null;
-    }
-
-    @Override
-    protected IExpression convertToDouble(IExpression expression, Class sourceType) {
-
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)){
-            // BEFORE: convert(string_expr, double)
-            // AFTER:  cast(cast(string_expr as decimal) as double)
-            IFunction inner = langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
-
-            return langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( inner, langFactory.createLiteral("double", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.DOUBLE);
-        }
-
-        // Just drop anything else
-        return null;
-    }
-
-    @Override
-    protected IExpression convertToBigDecimal(IExpression expression, Class sourceType) {
-        
-        if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)){
-            // BEFORE: convert(string_expr, bigdecimal)
-            // AFTER:  cast(string_expr as decimal)
-            return langFactory.createFunction("cast",  //$NON-NLS-1$
-                Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ),  //$NON-NLS-1$
-                TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
-        }
-
-        // Just drop anything else
-        return null;
-    }
-    
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/derby/DerbySQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -49,7 +49,6 @@
         
         //overrides of db2 functions
         registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier()); 
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new DerbyConvertModifier(getLanguageFactory())); 
     }  
  
     @Override

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/informix/InformixSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/informix/InformixSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -28,7 +28,7 @@
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.SourceSystemFunctions;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
 import org.teiid.connector.jdbc.translator.Translator;
 
 
@@ -39,7 +39,7 @@
 	@Override
 	public void initialize(ConnectorEnvironment env) throws ConnectorException {
 		super.initialize(env);
-    	registerFunctionModifier(SourceSystemFunctions.CONVERT, new DropFunctionModifier());
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, new ConvertModifier());
     }
 	
 	@Override

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/BitFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -22,10 +22,12 @@
 
 package org.teiid.connector.jdbc.mysql;
 
-import org.teiid.connector.api.SourceSystemFunctions;
+import java.util.Arrays;
+import java.util.List;
+
 import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.jdbc.translator.AliasModifier;
-import org.teiid.connector.language.IExpression;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 
@@ -41,9 +43,9 @@
 	 * Wrap the renamed function in a convert back to integer
 	 */
 	@Override
-	public IExpression modify(IFunction function) {
-		return langFactory.createFunction(SourceSystemFunctions.CONVERT, 
-				new IExpression[] {super.modify(function), langFactory.createLiteral(MySQLConvertModifier.SIGNED_INTEGER, TypeFacility.RUNTIME_TYPES.STRING)}, TypeFacility.RUNTIME_TYPES.INTEGER);
-	}	
+	public List<?> translate(IFunction function) {
+		modify(function);
+		return Arrays.asList(ConvertModifier.createConvertFunction(langFactory, function, TypeFacility.RUNTIME_NAMES.INTEGER));
+	}
 
 }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,182 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.mysql;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-
-
-
-/** 
- * @since 4.3
- */
-class MySQLConvertModifier extends BasicFunctionModifier {
-    
-    public static final String SIGNED_INTEGER = "SIGNED INTEGER"; //$NON-NLS-1$
-
-	private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
-    
-    private ILanguageFactory langFactory;
-    
-    MySQLConvertModifier(ILanguageFactory langFactory) {
-        this.langFactory = langFactory;
-    }
-
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-
-        if (args.get(0) != null && args.get(0) instanceof ILiteral && ((ILiteral)args.get(0)).getValue() == null ) {
-            if (args.get(1) != null && args.get(1) instanceof ILiteral) {
-                // This is a convert(null, ...) or cast(null as ...)
-                return DROP_MODIFIER.modify(function);
-            }
-        } 
-        
-        if (args.get(1) != null && args.get(1) instanceof ILiteral) {
-            String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
-            if (target.equals("string")) {  //$NON-NLS-1$ 
-                return convertToString(function);
-            } else if (target.equals("byte") || //$NON-NLS-1$
-                       target.equals("short") || //$NON-NLS-1$
-                       target.equals("integer")) {  //$NON-NLS-1$ 
-                return convertToNativeType(function, SIGNED_INTEGER);
-            } else if (target.equals("long") || //$NON-NLS-1$
-                       target.equals("biginteger")) { //$NON-NLS-1$ 
-                return convertToNativeType(function, "SIGNED"); //$NON-NLS-1$
-            } else if (target.equals("float") || //$NON-NLS-1$
-                       target.equals("double") || //$NON-NLS-1$
-                       target.equals("bigdecimal")) { //$NON-NLS-1$ 
-                return convertToNumeric(function); 
-            } else if (target.equals("date")) { //$NON-NLS-1$ 
-                return convertToDateTime("DATE", args.get(0), java.sql.Date.class); //$NON-NLS-1$
-            } else if (target.equals("time")) { //$NON-NLS-1$ 
-                return convertToDateTime("TIME", args.get(0), java.sql.Time.class); //$NON-NLS-1$
-            } else if (target.equals("timestamp")) { //$NON-NLS-1$ 
-                return convertToDateTime("TIMESTAMP", args.get(0), java.sql.Timestamp.class); //$NON-NLS-1$
-            } else if (target.equals("char")) { //$NON-NLS-1$ 
-                return convertToNativeType(function, "CHAR (1)"); //$NON-NLS-1$
-            } else if (target.equals("boolean")) {  //$NON-NLS-1$ 
-                return convertToBoolean(function);
-            }
-        }
-        return DROP_MODIFIER.modify(function); 
-    }
-    
-    private IExpression convertToString(IFunction function) {
-        int srcCode = getSrcCode(function);
-        switch(srcCode) {
-            case BOOLEAN:
-                // convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
-                List<ICompareCriteria> when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
-                List<ILiteral> then = Arrays.asList(langFactory.createLiteral("1", String.class)); //$NON-NLS-1$
-                IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
-                return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                // convert(src, string) --> convert(src, CHAR)
-                return convertToNativeType(function, "CHAR"); //$NON-NLS-1$
-            case DATE:
-                // convert (dateSrc, string) --> date_format(dateSrc, '%Y-%m-%d')
-                return convertDateTimeToString(function, "%Y-%m-%d"); //$NON-NLS-1$
-            case TIME:
-                // convert (timeSrc, string) --> date_format(timeSrc, '%H:%i:%S')
-                return convertDateTimeToString(function, "%H:%i:%S"); //$NON-NLS-1$
-            case TIMESTAMP:    
-                // convert (tsSrc, string) --> date_format(tsSrc, '%Y-%m-%d %H:%i:%S.%f')
-                return convertDateTimeToString(function, "%Y-%m-%d %H:%i:%S.%f"); //$NON-NLS-1$
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }
-    
-    private IExpression convertToNativeType(IFunction function, String targetType) {
-        List<IExpression> args = function.getParameters();
-        function.setName("convert"); //$NON-NLS-1$
-        args.set(1, langFactory.createLiteral(targetType, String.class));
-        return function;
-    }
-    
-    /**
-     * In version 5.1 and after, we can simple use convert(x, DECIMAL), but for backward compatibility we must do (x + 0.0)
-     * @param function
-     * @return
-     * @since 4.3
-     */
-    private IExpression convertToNumeric(IFunction function) {
-        // convert(x, float/double/bigdecimal) --> (x + 0.0)
-        return langFactory.createFunction("+", //$NON-NLS-1$
-                                          Arrays.asList(function.getParameters().get(0),
-                                                             langFactory.createLiteral(new Double(0.0), Double.class)),
-                                          Double.class);
-    }
-    
-    private IExpression convertToDateTime(String functionName, IExpression value, Class targetType) {
-        return langFactory.createFunction(functionName,
-                                           Arrays.asList(value),
-                                           targetType);
-    }
-    
-    private IExpression convertToBoolean(IFunction function) {
-        int srcCode = getSrcCode(function);
-        switch(srcCode) {
-            case STRING:
-                // convert(src, boolean) --> CASE src WHEN 'true' THEN 1 ELSE 0 END
-                // convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
-                List<ICompareCriteria> when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral("true", String.class)));
-                List<ILiteral> then = Arrays.asList(langFactory.createLiteral(Integer.valueOf(1), Integer.class)); //$NON-NLS-1$
-                IExpression elseExpr = langFactory.createLiteral(Integer.valueOf(0), Integer.class); //$NON-NLS-1$
-                return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }
-    
-    private IFunction convertDateTimeToString(IFunction function, String format) {
-        // convert (date, string) --> date_format(date, format)
-        List<IExpression> args = function.getParameters();
-        function.setName("date_format"); //$NON-NLS-1$
-        args.set(1, langFactory.createLiteral(format, String.class)); 
-        return function;
-    }
-    
-    private int getSrcCode(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        return ((Integer) typeMap.get(srcType)).intValue();
-    }         
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -28,30 +28,57 @@
 import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.List;
 
 import org.teiid.connector.api.ConnectorCapabilities;
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.jdbc.translator.LocateFunctionModifier;
 import org.teiid.connector.jdbc.translator.Translator;
+import org.teiid.connector.language.IFunction;
 
-
-
 /** 
  * @since 4.3
  */
 public class MySQLTranslator extends Translator {
-
+	
 	@Override
     public void initialize(ConnectorEnvironment env) throws ConnectorException {
         super.initialize(env);
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new MySQLConvertModifier(getLanguageFactory()));
         registerFunctionModifier(SourceSystemFunctions.BITAND, new BitFunctionModifier("&", getLanguageFactory())); //$NON-NLS-1$
         registerFunctionModifier(SourceSystemFunctions.BITNOT, new BitFunctionModifier("~", getLanguageFactory())); //$NON-NLS-1$
         registerFunctionModifier(SourceSystemFunctions.BITOR, new BitFunctionModifier("|", getLanguageFactory())); //$NON-NLS-1$
         registerFunctionModifier(SourceSystemFunctions.BITXOR, new BitFunctionModifier("^", getLanguageFactory())); //$NON-NLS-1$
         registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+        
+        //add in type conversion
+        ConvertModifier convertModifier = new ConvertModifier();
+        convertModifier.addTypeMapping("signed", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG); //$NON-NLS-1$
+    	//char(n) assume 4.1 or later
+    	convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("char", FunctionModifier.STRING); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("DATE")); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("TIME")); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("TIMESTAMP")); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%H:%i:%S")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d %H:%i:%S.%f")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addTypeConversion(new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList(function.getParameters().get(0), " + 0.0"); //$NON-NLS-1$
+			}
+		}, FunctionModifier.BIGDECIMAL, FunctionModifier.BIGINTEGER, FunctionModifier.FLOAT, FunctionModifier.DOUBLE);
+    	convertModifier.addNumericBooleanConversions();
+    	convertModifier.setWideningNumericImplicit(true);
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
     }  
 	
 	@Override

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/ConcatFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/ConcatFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/ConcatFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -22,13 +22,13 @@
 
 package org.teiid.connector.jdbc.oracle;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.language.ICriteria;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
@@ -44,7 +44,7 @@
  * CONCAT(a, b) ==> CASE WHEN (a is NULL OR b is NULL) THEN NULL ELSE CONCAT(a, b)
  * </code>   
  */
-public class ConcatFunctionModifier extends BasicFunctionModifier {
+public class ConcatFunctionModifier extends FunctionModifier {
     private ILanguageFactory langFactory;
     
     /** 
@@ -52,25 +52,23 @@
      */
     public ConcatFunctionModifier(ILanguageFactory langFactory) {
         this.langFactory = langFactory;
-    }
-
-    /** 
-     * @see org.teiid.connector.jdbc.translator.BasicFunctionModifier#modify(org.teiid.connector.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
-        List when = new ArrayList();
+    }
+    
+    @Override
+    public List<?> translate(IFunction function) {
+    	List when = new ArrayList();
         IExpression a = function.getParameters().get(0);
         IExpression b = function.getParameters().get(1);
         List crits = new ArrayList();
         
         ILiteral nullValue = langFactory.createLiteral(null, TypeFacility.RUNTIME_TYPES.STRING);
         if (isNull(a)) {
-        	return nullValue;
+        	return Arrays.asList(nullValue);
         } else if (!isNotNull(a)) {
         	crits.add(langFactory.createIsNullCriteria(a, false));
         }
         if (isNull(b)) {
-        	return nullValue;
+        	return Arrays.asList(nullValue);
         } else if (!isNotNull(b)) {
         	crits.add(langFactory.createIsNullCriteria(b, false));
         }
@@ -78,7 +76,7 @@
         ICriteria crit = null;
         
         if (crits.isEmpty()) {
-        	return function;
+        	return null;
         } else if (crits.size() == 1) {
         	crit = (ICriteria)crits.get(0);
         } else {
@@ -86,7 +84,7 @@
         }
         when.add(crit);
         List then = Arrays.asList(new IExpression[] {nullValue}); 
-        return langFactory.createSearchedCaseExpression(when, then, function, TypeFacility.RUNTIME_TYPES.STRING);
+        return Arrays.asList(langFactory.createSearchedCaseExpression(when, then, function, TypeFacility.RUNTIME_TYPES.STRING));
     }
     
     private boolean isNotNull(IExpression expr) {

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,9 +25,8 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
 import org.teiid.connector.jdbc.translator.FunctionModifier;
-import org.teiid.connector.language.*;
+import org.teiid.connector.language.IFunction;
 
 
 /**
@@ -38,32 +37,16 @@
  * 4) week
  * 5) quarter
  */
-public class DayWeekQuarterFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
-    private ILanguageFactory langFactory;
+public class DayWeekQuarterFunctionModifier extends FunctionModifier {
     private String format;
     
-    public DayWeekQuarterFunctionModifier(ILanguageFactory langFactory, String format) {
-        this.langFactory = langFactory;
+    public DayWeekQuarterFunctionModifier(String format) {
         this.format = format;
     }
     
-    /* 
-     * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-
-        IFunction inner = langFactory.createFunction("TO_CHAR",  //$NON-NLS-1$
-            Arrays.asList( 
-                args.get(0), 
-                langFactory.createLiteral(format, String.class)),  
-                String.class);
-            
-        IFunction outer = langFactory.createFunction("TO_NUMBER",  //$NON-NLS-1$
-            Arrays.asList(inner),  
-                Integer.class);
-                                
-        return outer;    
+    @Override
+    public List<?> translate(IFunction function) {
+        return Arrays.asList("to_number(TO_CHAR(",function.getParameters().get(0), ", '", format,"'))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$    
     }
 }
 

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/LeftOrRightFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/LeftOrRightFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -26,26 +26,25 @@
 import java.util.List;
 
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
 import org.teiid.connector.jdbc.translator.FunctionModifier;
-import org.teiid.connector.language.*;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
 
 
 /**
  * Convert left(string, count) --> substr(string, 1, count)
  * or right(string, count) --> substr(string, -1 * count) - we lack a way to express a unary negation
  */
-public class LeftOrRightFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
+public class LeftOrRightFunctionModifier extends FunctionModifier {
     private ILanguageFactory langFactory;
     
     public LeftOrRightFunctionModifier(ILanguageFactory langFactory) {
         this.langFactory = langFactory;
     }
     
-    /* 
-     * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
+    @Override
+    public List<?> translate(IFunction function) {
         List<IExpression> args = function.getParameters();
         IFunction func = null;
         
@@ -68,6 +67,6 @@
                     String.class);      
         }
 
-        return func;    
+        return Arrays.asList(func);    
     }
 }

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/Log10FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/Log10FunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/Log10FunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -24,12 +24,14 @@
 
 import java.util.List;
 
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.jdbc.translator.FunctionModifier;
-import org.teiid.connector.language.*;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
 
 
-public class Log10FunctionModifier extends BasicFunctionModifier implements FunctionModifier {
+public class Log10FunctionModifier extends FunctionModifier {
     
     private ILanguageFactory languageFactory;
 
@@ -37,13 +39,14 @@
         this.languageFactory = languageFactory;
     }
 
-    public IExpression modify(IFunction function) {
+    @Override
+    public List<?> translate(IFunction function) {
         function.setName("log"); //$NON-NLS-1$
         
         List<IExpression> args = function.getParameters();
         args.add(args.get(0));
-        args.set(0, languageFactory.createLiteral(new Integer(10), Integer.class));
-        return function;
+        args.set(0, languageFactory.createLiteral(new Integer(10), TypeFacility.RUNTIME_TYPES.INTEGER));
+        return null;
     }
 
 }

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,7 +25,8 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
@@ -36,7 +37,7 @@
  * Convert the MONTHNAME etc. function into an equivalent Oracle function.  
  * Format: to_char(timestampvalue/dayvalue, 'Month'/'Day') 
  */
-public class MonthOrDayNameFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
+public class MonthOrDayNameFunctionModifier extends FunctionModifier {
     private ILanguageFactory langFactory;
     private String format;
     
@@ -45,22 +46,20 @@
         this.format = format;
     }
     
-    /* 
-     * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
+    @Override
+    public List<?> translate(IFunction function) {
         List<IExpression> args = function.getParameters();
     
         IFunction func = langFactory.createFunction("TO_CHAR",  //$NON-NLS-1$
             Arrays.asList( 
                 args.get(0), 
-                langFactory.createLiteral(format, String.class)),  
-            String.class);
+                langFactory.createLiteral(format, TypeFacility.RUNTIME_TYPES.STRING)),  
+            TypeFacility.RUNTIME_TYPES.STRING);
         
         // For some reason, these values have trailing spaces
-        IFunction trimFunc = langFactory.createFunction("RTRIM",  //$NON-NLS-1$
-            Arrays.asList( func ), String.class);
+        IFunction trimFunc = langFactory.createFunction(SourceSystemFunctions.RTRIM,
+            Arrays.asList( func ), TypeFacility.RUNTIME_TYPES.STRING);
         
-        return trimFunc;    
+        return Arrays.asList(trimFunc);    
     }
 }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,532 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.oracle;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.jdbc.translator.FunctionModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILiteral;
-
-
-/**
- */
-public class OracleConvertModifier extends BasicFunctionModifier implements FunctionModifier {     
-    private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
-    private ILanguageFactory langFactory;
-    
-    public OracleConvertModifier(ILanguageFactory langFactory, ConnectorLogger logger) {
-        this.langFactory = langFactory;
-    }
-
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        IExpression modified = null;
-
-        String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
-        if (target.equals("string")) {  //$NON-NLS-1$ 
-            modified = convertToString(function);
-        } else if (target.equals("short")) {  //$NON-NLS-1$ 
-            modified = convertToShort(function);
-        } else if (target.equals("integer")) { //$NON-NLS-1$ 
-            modified = convertToInteger(function);
-        } else if (target.equals("long")) { //$NON-NLS-1$ 
-            modified = convertToLong(function);
-        } else if (target.equals("biginteger")) { //$NON-NLS-1$ 
-            modified = convertToBigInteger(function);
-        } else if (target.equals("float")) { //$NON-NLS-1$ 
-            modified = convertToFloat(function);
-        } else if (target.equals("double")) { //$NON-NLS-1$ 
-            modified = convertToDouble(function);
-        } else if (target.equals("bigdecimal")) { //$NON-NLS-1$ 
-            modified = convertToBigDecimal(function);
-        } else if (target.equals("date")) { //$NON-NLS-1$ 
-            modified = convertToDate(function);
-        } else if (target.equals("time")) { //$NON-NLS-1$ 
-            modified = convertToTime(function);
-        } else if (target.equals("timestamp")) { //$NON-NLS-1$ 
-            modified = convertToTimestamp(function);
-        } else if (target.equals("char")) { //$NON-NLS-1$ 
-            modified = convertToChar(function);
-        } else if (target.equals("boolean")) {  //$NON-NLS-1$ 
-            modified = convertToBoolean(function);
-        } else if (target.equals("byte")) {  //$NON-NLS-1$ 
-            modified = convertToByte(function);
-        } else {
-            modified = DROP_MODIFIER.modify(function);          
-        }
-        return modified;
-    }
-    
-    private IExpression convertToDate(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        int srcCode = getSrcCode(srcType);
-
-        switch(srcCode) {
-            case STRING:
-                // convert(STRING, date) --> to_date(STRING, format)
-                String format = "YYYY-MM-DD";  //$NON-NLS-1$ 
-                convert = dateTypeHelper("to_date", Arrays.asList(args.get(0),  //$NON-NLS-1$ 
-                    langFactory.createLiteral(format, String.class)), java.sql.Date.class);
-                break;
-            case TIMESTAMP:
-                // convert(TSELEMENT, date) --> trunc(TSELEMENT) 
-                convert = dateTypeHelper("trunc", Arrays.asList(args.get(0)), java.sql.Date.class);  //$NON-NLS-1$ 
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-
-    /**
-     * TODO: need to remove the prepend 1970-01-01 and the {ts''}
-     * @param function
-     * @return IExpression
-     */
-    private IExpression convertToTime(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        String format = "YYYY-MM-DD HH24:MI:SS";  //$NON-NLS-1$ 
-        
-        int srcCode = getSrcCode(srcType);
-        switch(srcCode) {
-            case STRING:
-                //convert(STRING, time) --> to_date('1970-01-01 ' || to_char(timevalue, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')
-                IFunction inner0 = langFactory.createFunction("to_char",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        args.get(0),
-                        langFactory.createLiteral("HH24:MI:SS", String.class)),  //$NON-NLS-1$
-                        String.class); 
-                        
-                IExpression prependedPart0 = langFactory.createFunction("||",  //$NON-NLS-1$
-                Arrays.asList(
-                    langFactory.createLiteral("1970-01-01 ", String.class),  //$NON-NLS-1$
-                    inner0),
-                    String.class);    
-                    
-                convert = langFactory.createFunction("to_date",  //$NON-NLS-1$
-                    Arrays.asList(prependedPart0,
-                        langFactory.createLiteral(format, String.class)), 
-                        java.sql.Time.class);   
-                break;                                                                 
-            case TIMESTAMP:
-                // convert(timestamp, time) 
-                // --> to_date(('1970-01-01 ' || to_char(timestampvalue, 'HH24:MI:SS'))),  
-                //         'YYYY-MM-DD HH24:MI:SS') 
-                IFunction inner = langFactory.createFunction("to_char",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        args.get(0),
-                        langFactory.createLiteral("HH24:MI:SS", String.class)),  //$NON-NLS-1$
-                        String.class); 
-                
-                IExpression prependedPart =  langFactory.createFunction("||",  //$NON-NLS-1$
-                    Arrays.asList(
-                        langFactory.createLiteral("1970-01-01 ", String.class),  //$NON-NLS-1$
-                        inner),
-                        String.class);
-                                          
-                convert = langFactory.createFunction("to_date",  //$NON-NLS-1$
-                    Arrays.asList(prependedPart,
-                        langFactory.createLiteral(format, String.class)), 
-                        java.sql.Time.class);                                     
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }    
-    
-    private IExpression convertToTimestamp(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        int srcCode = getSrcCode(srcType);
-        switch(srcCode) {
-            case STRING:
-                // convert(STRING, timestamp) --> to_date(timestampvalue, 'YYYY-MM-DD HH24:MI:SS.FF')))  
-                String format = "YYYY-MM-DD HH24:MI:SS.FF";  //$NON-NLS-1$
-                convert = dateTypeHelper("to_timestamp", Arrays.asList(args.get(0),  //$NON-NLS-1$ 
-                    langFactory.createLiteral(format, String.class)), java.sql.Timestamp.class);
-                break;
-            case TIME:
-            case DATE:
-            	convert = dateTypeHelper("cast", Arrays.asList(args.get(0),  //$NON-NLS-1$ 
-                        langFactory.createLiteral("timestamp", String.class)), java.sql.Timestamp.class); //$NON-NLS-1$
-                break; 
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToChar(IFunction function) {
-        // two cases: 
-        //          1) 2-byte: convert(string, char) --> cast(stringkey AS char(2))
-        //          2) single bit: just drop
-        // TODO: case 1)
-        return  DROP_MODIFIER.modify(function);         
-    }
-
-    private IExpression convertToString(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        String format = null;
-
-        int srcCode = getSrcCode(function);
-        switch(srcCode) { // convert(input, string) --> to_char(input)
-            case BOOLEAN:
-                convert = langFactory.createFunction("decode", Arrays.asList( //$NON-NLS-1$
-                        args.get(0),
-                        langFactory.createLiteral(new Integer(0), Integer.class),
-                        langFactory.createLiteral("false", String.class), //$NON-NLS-1$
-                        langFactory.createLiteral(new Integer(1), Integer.class),
-                        langFactory.createLiteral("true", String.class) ),  //$NON-NLS-1$
-                    String.class);
-                
-                break;
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createStringFunction(args.get(0));
-                break;
-            // convert(input, string) --> to_char(input, format)
-            case DATE:
-                format = "YYYY-MM-DD"; //$NON-NLS-1$
-                convert = createStringFunction(args.get(0), format); 
-                break;
-            case TIME:
-                format = "HH24:MI:SS"; //$NON-NLS-1$
-                convert = createStringFunction(args.get(0), format); 
-                break;
-            case TIMESTAMP:
-                convert = createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS.FF"); //$NON-NLS-1$ 
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function);
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToBoolean(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-        switch(srcCode) {
-            case STRING:
-                // convert(src, boolean) --> decode(string, 'true', 1, 'false', 0)
-                convert = booleanHelper(function);  
-                break;  
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function);
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToByte(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case SHORT: 
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:                     
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToShort(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case BYTE:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToInteger(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-
-    private IExpression convertToLong(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToBigInteger(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToFloat(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case DOUBLE: 
-            case BIGDECIMAL:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }   
-       
-    private IExpression convertToDouble(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            case BIGDECIMAL:   
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToBigDecimal(IFunction function) {
-        IExpression convert = null;
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                convert = stringSrcHelper(function);
-                break;  
-            case BOOLEAN:
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }  
-
-    private IFunction dateTypeHelper(String functionName, List<IExpression> args, Class target) {
-        IFunction convert = langFactory.createFunction(functionName,  
-            args, target);
-        return convert;          
-    }
-       
-    private IFunction booleanHelper(IFunction function) {
-        // using decode(value, 'true', 1, 'false', 0)
-        List<IExpression> args = function.getParameters();
-       
-        return langFactory.createFunction("decode", //$NON-NLS-1$
-        		Arrays.asList(
-        	            args.get(0),
-        	            langFactory.createLiteral("true", String.class), //$NON-NLS-1$ 
-        	            langFactory.createLiteral(new Byte((byte)1), Byte.class),
-        	            langFactory.createLiteral("false", String.class), //$NON-NLS-1$ 
-        	            langFactory.createLiteral(new Byte((byte)0), Byte.class)                        
-        	        ), java.lang.Boolean.class);  
-    }
-            
-    private IExpression stringSrcHelper(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        // switch the target type
-        String functionName = "to_number"; //$NON-NLS-1$
-        int targetCode = getTargetCode(function.getType());
-        switch(targetCode) {
-            case BYTE:
-                convert = createFunction(functionName, args.get(0), Byte.class);
-                break;
-            case SHORT:
-                convert = createFunction(functionName, args.get(0), Short.class);
-                break;                    
-            case INTEGER:
-                convert = createFunction(functionName, args.get(0), Integer.class);
-                break;
-            case LONG:
-                convert = createFunction(functionName, args.get(0), Long.class);
-                break;           
-            case BIGINTEGER:
-                convert = createFunction(functionName, args.get(0), java.math.BigInteger.class);
-                break;    
-            case FLOAT:
-                convert = createFunction(functionName, args.get(0), Float.class);
-                break;
-            case DOUBLE:
-                convert = createFunction(functionName, args.get(0), Double.class);
-                break;
-            case BIGDECIMAL:
-                convert = createFunction(functionName, args.get(0), java.math.BigDecimal.class);
-                break;   
-            default:
-                convert = DROP_MODIFIER.modify(function);
-                break;               
-        }             
-        return convert;
-    } 
-          
-    private IFunction createFunction(String functionName, IExpression args0, Class targetClass) {
-        IFunction created = langFactory.createFunction(functionName,
-            Arrays.asList(args0), targetClass);
-        return created;            
-    }
-
-    private IFunction createStringFunction(IExpression args0, String format) {
-        IFunction created = langFactory.createFunction("to_char", //$NON-NLS-1$ 
-            Arrays.asList(args0, langFactory.createLiteral(format, String.class)), 
-            String.class);
-        return created;            
-    }
-    
-    private IFunction createStringFunction(IExpression args) {
-        IFunction created = langFactory.createFunction("to_char", //$NON-NLS-1$ 
-            Arrays.asList( args ), String.class); 
-        return created;
-    }
-    
-    private int getSrcCode(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        return ((Integer) typeMap.get(srcType)).intValue();
-    }
-    
-    private int getSrcCode(Class source) {
-        return ((Integer) typeMap.get(source)).intValue();
-    }
-    
-    private int getTargetCode(Class target) {
-        return ((Integer) typeMap.get(target)).intValue();
-    }           
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -31,6 +31,7 @@
 import java.sql.Statement;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -41,7 +42,9 @@
 import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.jdbc.JDBCPlugin;
 import org.teiid.connector.jdbc.translator.AliasModifier;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
 import org.teiid.connector.jdbc.translator.ExtractFunctionModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.jdbc.translator.LocateFunctionModifier;
 import org.teiid.connector.jdbc.translator.Translator;
 import org.teiid.connector.language.ICommand;
@@ -84,7 +87,6 @@
         registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.LOG10, new Log10FunctionModifier(getLanguageFactory())); 
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new OracleConvertModifier(getLanguageFactory(), getEnvironment().getLogger())); 
         registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
         registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier()); 
         registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier()); 
@@ -93,40 +95,76 @@
         registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier()); 
         registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.WEEK, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "WW"));//$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.QUARTER, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "Q"));//$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "D"));//$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "DDD"));//$NON-NLS-1$ 
+        registerFunctionModifier(SourceSystemFunctions.WEEK, new DayWeekQuarterFunctionModifier("WW"));//$NON-NLS-1$ 
+        registerFunctionModifier(SourceSystemFunctions.QUARTER, new DayWeekQuarterFunctionModifier("Q"));//$NON-NLS-1$ 
+        registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new DayWeekQuarterFunctionModifier("D"));//$NON-NLS-1$ 
+        registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DayWeekQuarterFunctionModifier("DDD"));//$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true)); //$NON-NLS-1$
         registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));//$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
         registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
         registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory())); 
+        
+        //spatial functions
         registerFunctionModifier(RELATE, new OracleSpatialFunctionModifier());
         registerFunctionModifier(NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
         registerFunctionModifier(FILTER, new OracleSpatialFunctionModifier());
         registerFunctionModifier(WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
+        
+        //add in type conversion
+        ConvertModifier convertModifier = new ConvertModifier();
+    	convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("date", FunctionModifier.DATE, FunctionModifier.TIME); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+    		@Override
+    		public List<?> translate(IFunction function) {
+    			return Arrays.asList("to_date('1970-01-01 ' || to_char(",function.getParameters().get(0),", 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+    		}
+    	});
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList("trunc(cast(",function.getParameters().get(0)," AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.FF")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_date", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", "YYYY-MM-DD HH24:MI:SS.FF")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_char"), FunctionModifier.STRING); //$NON-NLS-1$
+    	//NOTE: numeric handling in Oracle is split only between integral vs. floating/decimal types
+    	convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_number"), //$NON-NLS-1$
+    			FunctionModifier.FLOAT, FunctionModifier.DOUBLE, FunctionModifier.BIGDECIMAL);
+    	convertModifier.addTypeConversion(new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				if (Number.class.isAssignableFrom(function.getParameters().get(0).getType())) {
+					return Arrays.asList("trunc(", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+				return Arrays.asList("trunc(to_number(", function.getParameters().get(0), "))"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		}, 
+		FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG,	FunctionModifier.BIGINTEGER);
+    	convertModifier.addNumericBooleanConversions();
+    	convertModifier.setWideningNumericImplicit(true);
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
     }
     
-    @Override
-    public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
-    	if (!(command instanceof IInsert)) {
-    		return command;
-    	}
-    	
+    public void handleInsertSequences(IInsert insert) throws ConnectorException {
         /* 
          * If a missing auto_increment column is modeled with name in source indicating that an Oracle Sequence 
          * then pull the Sequence name out of the name in source of the column.
          */
-    	IInsert insert = (IInsert)command;
-    	
     	if (!(insert.getValueSource() instanceof IInsertExpressionValueSource)) {
-    		return command;
+    		return;
     	}
     	IInsertExpressionValueSource values = (IInsertExpressionValueSource)insert.getValueSource();
     	List<Element> allElements = insert.getGroup().getMetadataObject().getChildren();
     	if (allElements.size() == values.getValues().size()) {
-    		return command;
+    		return;
     	}
     	
     	int index = 0;
@@ -167,11 +205,18 @@
             insert.getElements().add(index, this.getLanguageFactory().createElement(element.getName(), insert.getGroup(), element, element.getJavaType()));
             values.getValues().add(index, sequenceElement);
 		}
-        return command;
     }
     
     @Override
     public List<?> translateCommand(ICommand command, ExecutionContext context) {
+    	if (command instanceof IInsert) {
+    		try {
+				handleInsertSequences((IInsert)command);
+			} catch (ConnectorException e) {
+				throw new RuntimeException(e);
+			}
+    	}
+    	
     	if (!(command instanceof IQueryCommand)) {
     		return null;
     	}
@@ -309,7 +354,7 @@
     }
     
     @Override
-    public void bindValue(PreparedStatement stmt, Object param, Class paramType, int i) throws SQLException {
+    public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
     	if(param == null && Object.class.equals(paramType)){
     		//Oracle drive does not support JAVA_OBJECT type
     		stmt.setNull(i, Types.LONGVARBINARY);

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSpatialFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSpatialFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSpatialFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,13 +25,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILiteral;
 
 
-public class OracleSpatialFunctionModifier extends BasicFunctionModifier {
+public class OracleSpatialFunctionModifier extends FunctionModifier {
 
     /**
      * If either of the first two parameters are a Literal String, then we need to put the literal itself in the SQL

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -38,6 +38,7 @@
 
 	@Override
 	public List<?> translate(IFunction function) {
+		modify(function);
 		List<Object> parts = new ArrayList<Object>();
 		List<IExpression> params = function.getParameters();
 		parts.add("position("); //$NON-NLS-1$

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,201 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.postgresql;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.jdbc.translator.FunctionModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.ICompareCriteria.Operator;
-
-
-/**
- */
-class PostgreSQLConvertModifier extends BasicFunctionModifier implements FunctionModifier {     
-    private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
-    private ILanguageFactory langFactory;
-    
-    PostgreSQLConvertModifier(ILanguageFactory langFactory) {
-        this.langFactory = langFactory;
-    }
-
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-
-        if (args.get(0) != null && args.get(0) instanceof ILiteral && ((ILiteral)args.get(0)).getValue() == null ) {
-            if (args.get(1) != null && args.get(1) instanceof ILiteral) {
-                // This is a convert(null, ...) or cast(null as ...)
-                return DROP_MODIFIER.modify(function);
-            }
-        } 
-        
-        if (args.get(1) != null && args.get(1) instanceof ILiteral) {
-            String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
-            if (target.equals("string")) {  //$NON-NLS-1$ 
-                return convertToString(function);
-            } else if (target.equals("short")) {  //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "smallint", Short.class); //$NON-NLS-1$
-            } else if (target.equals("integer")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "integer", Integer.class); //$NON-NLS-1$
-            } else if (target.equals("long")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "bigint", Long.class); //$NON-NLS-1$
-            } else if (target.equals("biginteger")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "numeric", BigInteger.class); //$NON-NLS-1$
-            } else if (target.equals("float")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "real", Float.class); //$NON-NLS-1$
-            } else if (target.equals("double")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "float8", Double.class); //$NON-NLS-1$
-            } else if (target.equals("bigdecimal")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "decimal", BigDecimal.class); //$NON-NLS-1$
-            } else if (target.equals("date")) { //$NON-NLS-1$ 
-                return convertToDate(function);
-            } else if (target.equals("time")) { //$NON-NLS-1$ 
-                return convertToTime(function);
-            } else if (target.equals("timestamp")) { //$NON-NLS-1$ 
-                return convertToTimestamp(function);
-            } else if (target.equals("char")) { //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "varchar", String.class); //$NON-NLS-1$
-            } else if (target.equals("boolean")) {  //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "boolean", Boolean.class); //$NON-NLS-1$
-            } else if (target.equals("byte")) {  //$NON-NLS-1$ 
-                return createCastFunction(args.get(0), "smallint", Byte.class); //$NON-NLS-1$
-            }
-        }
-        return DROP_MODIFIER.modify(function); 
-    }
-    
-    private IExpression convertToDate(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        int srcCode = getSrcCode(function);
-
-        switch(srcCode) {
-            case STRING:
-                return createConversionFunction("to_date", args.get(0), "YYYY-MM-DD", java.sql.Date.class); //$NON-NLS-1$//$NON-NLS-2$
-            case TIMESTAMP:
-                return createCastFunction(args.get(0), "date", java.sql.Date.class); //$NON-NLS-1$
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }
-
-    private IExpression convertToTime(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        
-        int srcCode = getSrcCode(function);
-        switch(srcCode) {
-            case STRING:
-                //convert(STRING, time) --> to_timestamp('1970-01-01 ' || timevalue, 'YYYY-MM-DD HH24:MI:SS')
-                IExpression prependedPart0 = langFactory.createFunction("||",  //$NON-NLS-1$
-                                                                          Arrays.asList(langFactory.createLiteral("1970-01-01 ", String.class), args.get(0)),  //$NON-NLS-1$
-                                                                          String.class);    
-                    
-                return createConversionFunction("to_timestamp", prependedPart0, "YYYY-MM-DD HH24:MI:SS", java.sql.Time.class); //$NON-NLS-1$ //$NON-NLS-2$
-            case TIMESTAMP:
-                return createCastFunction(args.get(0), "time", java.sql.Time.class); //$NON-NLS-1$
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }    
-    
-    /**
-     * This works only for Oracle 9i.
-     * @param src
-     * @return IFunction
-     */
-    private IExpression convertToTimestamp(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        int srcCode = getSrcCode(function);
-        switch(srcCode) {
-            case STRING:
-                // convert(STRING, timestamp) --> to_date(timestampvalue, 'YYYY-MM-DD HH24:MI:SS'))) from smalla 
-                return createConversionFunction("to_timestamp", args.get(0), "YYYY-MM-DD HH24:MI:SS.UF", java.sql.Timestamp.class); //$NON-NLS-1$ //$NON-NLS-2$
-            case TIME:
-            case DATE:
-                // convert(DATE, timestamp) --> to_date(to_char(DATE, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')
-                IFunction inner = createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS");  //$NON-NLS-1$
-                        
-                return createConversionFunction("to_timestamp", inner, "YYYY-MM-DD HH24:MI:SS", java.sql.Timestamp.class); //$NON-NLS-1$ //$NON-NLS-2$
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }
-    
-    private IExpression convertToString(IFunction function) {
-        List<IExpression> args = function.getParameters();
-
-        int srcCode = getSrcCode(function);
-        switch(srcCode) { 
-            case BOOLEAN:
-                // convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
-                List when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
-                List then = Arrays.asList(langFactory.createLiteral("1", String.class)); //$NON-NLS-1$
-                IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
-                return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                // convert(src, string) --> cast (src AS varchar)
-                return createCastFunction(args.get(0), "varchar", String.class); //$NON-NLS-1$
-            // convert(input, string) --> to_char(input, format)
-            case DATE:
-                return createStringFunction(args.get(0), "YYYY-MM-DD"); //$NON-NLS-1$
-            case TIME:
-                return createStringFunction(args.get(0), "HH24:MI:SS"); //$NON-NLS-1$
-            case TIMESTAMP:
-                return createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS.US"); //$NON-NLS-1$
-            default:
-                return DROP_MODIFIER.modify(function);
-        }
-    }
-
-    private IFunction createStringFunction(IExpression args0, String format) {
-        return createConversionFunction("to_char", args0, format, String.class); //$NON-NLS-1$           
-    }
-    
-    private IFunction createCastFunction(IExpression value, String typeName, Class targetClass) {
-        return createConversionFunction("cast", value, typeName, targetClass); //$NON-NLS-1$
-    }
-
-    private IFunction createConversionFunction(String functionName, IExpression value, String target, Class targetClass) {
-        return langFactory.createFunction(functionName, Arrays.asList(value, langFactory.createLiteral(target, String.class)), targetClass);
-    }
-    
-    private int getSrcCode(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        return ((Integer) typeMap.get(srcType)).intValue();
-    }
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -37,13 +37,17 @@
 import org.teiid.connector.jdbc.oracle.LeftOrRightFunctionModifier;
 import org.teiid.connector.jdbc.oracle.MonthOrDayNameFunctionModifier;
 import org.teiid.connector.jdbc.translator.AliasModifier;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
 import org.teiid.connector.jdbc.translator.EscapeSyntaxModifier;
 import org.teiid.connector.jdbc.translator.ExtractFunctionModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.jdbc.translator.Translator;
 import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageObject;
 import org.teiid.connector.language.ILimit;
-import org.teiid.connector.visitor.framework.HierarchyVisitor;
+import org.teiid.connector.language.ILiteral;
 import org.teiid.connector.visitor.util.SQLReservedWords;
 
 
@@ -87,15 +91,58 @@
         registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier()); 
         registerFunctionModifier(SourceSystemFunctions.WEEK, new ExtractFunctionModifier()); 
         registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier()); 
-        
+        registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+        registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
+
         //specific to 8.2 client or later
         registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
         registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
-        
-        registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory())); 
-        
-        registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+                
+        //add in type conversion
+        ConvertModifier convertModifier = new ConvertModifier();
+        convertModifier.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("integer", FunctionModifier.INTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("float8", FunctionModifier.DOUBLE); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList(function.getParameters().get(0), " + TIMESTAMP '1970-01-01'"); //$NON-NLS-1$
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return Arrays.asList("cast(date_trunc('second', ", function.getParameters().get(0), ") AS time)"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.UF")); //$NON-NLS-1$ //$NON-NLS-2$
+    	convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				IExpression stringValue = function.getParameters().get(0);
+				return Arrays.asList("CASE WHEN ", stringValue, " THEN 'true' WHEN not(", stringValue, ") THEN 'false' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		});
+    	convertModifier.addSourceConversion(new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				((ILiteral)function.getParameters().get(1)).setValue("integer"); //$NON-NLS-1$
+				return null;
+			}
+		}, FunctionModifier.BOOLEAN);
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier); 
     }    
     
     @Override
@@ -118,7 +165,7 @@
     
     @Override
     public String translateLiteralTimestamp(Timestamp timestampValue) {
-        return "to_timestamp('" + formatDateValue(timestampValue) + "', 'YYYY-MM-DD HH24:MI:SS.US')"; //$NON-NLS-1$//$NON-NLS-2$ 
+        return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$ 
     }
     
     @Override
@@ -142,23 +189,18 @@
      * @since 4.3
      */
     @Override
-    public ICommand modifyCommand(ICommand command, ExecutionContext context)
-    		throws ConnectorException {
-    	HierarchyVisitor visitor = new HierarchyVisitor() {
-    		@Override
-    		public void visit(IAggregate obj) {
-                if (TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(obj.getExpression().getType())) {
-                	if (obj.getName().equalsIgnoreCase(SQLReservedWords.MIN)) {
-                		obj.setName("bool_and"); //$NON-NLS-1$
-                	} else if (obj.getName().equalsIgnoreCase(SQLReservedWords.MAX)) {
-                		obj.setName("bool_or"); //$NON-NLS-1$
-                	}
-                }
-    		}
-   		};
-    	
-    	command.acceptVisitor(visitor);
-    	return command;
+    public List<?> translate(ILanguageObject obj, ExecutionContext context) {
+    	if (obj instanceof IAggregate) {
+    		IAggregate agg = (IAggregate)obj;
+    		if (TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getExpression().getType())) {
+            	if (agg.getName().equalsIgnoreCase(SQLReservedWords.MIN)) {
+            		agg.setName("bool_and"); //$NON-NLS-1$
+            	} else if (agg.getName().equalsIgnoreCase(SQLReservedWords.MAX)) {
+            		agg.setName("bool_or"); //$NON-NLS-1$
+            	}
+            }
+    	}
+    	return super.translate(obj, context);
     }
     
     @Override

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerCapabilities.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerCapabilities.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -46,7 +46,7 @@
         supportedFunctions.add("ACOS"); //$NON-NLS-1$
         supportedFunctions.add("ASIN"); //$NON-NLS-1$
         supportedFunctions.add("ATAN"); //$NON-NLS-1$
-        //supportedFunctons.add("ATAN2"); //$NON-NLS-1$
+        supportedFunctions.add("ATAN2"); //$NON-NLS-1$
         supportedFunctions.add("COS"); //$NON-NLS-1$
         supportedFunctions.add("COT"); //$NON-NLS-1$
         supportedFunctions.add("DEGREES"); //$NON-NLS-1$
@@ -125,5 +125,14 @@
     
     public boolean supportsRowLimit() {
         return true;
-    }
+    }
+    
+    @Override
+    public boolean supportsIntersect() {
+    	return true;
+    }
+    
+    public boolean supportsExcept() {
+    	return true;
+    };
 }

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -24,43 +24,31 @@
  */
 package org.teiid.connector.jdbc.sqlserver;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.jdbc.sybase.SybaseSQLTranslator;
-import org.teiid.connector.jdbc.translator.AliasModifier;
-import org.teiid.connector.jdbc.translator.EscapeSyntaxModifier;
+import org.teiid.connector.language.IFunction;
 
 /**
  * Updated to assume the use of the DataDirect, 2005 driver, or later.
  */
 public class SqlServerSQLTranslator extends SybaseSQLTranslator {
-
-    public void initialize(ConnectorEnvironment env) throws ConnectorException {
-        super.initialize(env);
-        //TEIID-31 remove mod modifier for SQL Server 2008
-        registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
-        registerFunctionModifier(SourceSystemFunctions.REPEAT, new AliasModifier("replicate")); //$NON-NLS-1$
-        registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
-        registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
-    }
+	
+	//TEIID-31 remove mod modifier for SQL Server 2008
+	
+	@Override
+	protected List<Object> convertDateToString(IFunction function) {
+		return Arrays.asList("replace(convert(varchar, ", function.getParameters().get(0), ", 102), '.', '-')"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
     
+	@Override
+	protected List<?> convertTimestampToString(IFunction function) {
+		return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 21)"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+	
     @Override
-    public String getLengthFunctionName() {
-    	return "len"; //$NON-NLS-1$
-    }
-    
-    @Override
     public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
     	return SqlServerCapabilities.class;
     }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/ModFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/ModFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/ModFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.sybase;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.api.TypeFacility.RUNTIME_TYPES;
-import org.teiid.connector.jdbc.translator.AliasModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-
-public class ModFunctionModifier extends AliasModifier {
-
-	private ILanguageFactory langFactory;
-    
-    public ModFunctionModifier(ILanguageFactory langFactory) {
-    	super("%"); //$NON-NLS-1$
-        this.langFactory = langFactory;
-    }
-	
-	@Override
-	public IExpression modify(IFunction function) {
-		List<IExpression> expressions = function.getParameters();
-		if (RUNTIME_TYPES.INTEGER.equals(expressions.get(0).getType())) {
-			return super.modify(function);
-		}
-		//x % y => x - floor(x / y) * y
-		IFunction divide = langFactory.createFunction("/", new ArrayList<IExpression>(expressions), expressions.get(0).getType()); //$NON-NLS-1$
-		
-		IFunction floor = langFactory.createFunction("floor", Arrays.asList(divide), divide.getType()); //$NON-NLS-1$
-		
-		List<IExpression> multArgs = Arrays.asList(floor, expressions.get(1));
-		IFunction mult = langFactory.createFunction("*", multArgs, multArgs.get(1).getType()); //$NON-NLS-1$
-
-		List<IExpression> minusArgs = Arrays.asList(expressions.get(0), mult);
-		
-		return langFactory.createFunction("-", minusArgs, minusArgs.get(0).getType()); //$NON-NLS-1$
-	}
-	
-}

Copied: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SubstringFunctionModifier.java (from rev 1286, trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SubstringFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SubstringFunctionModifier.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SubstringFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.sybase;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+
+/**
+ * Common logic for Substring modifiers requiring 3 parameters
+ */
+public class SubstringFunctionModifier extends FunctionModifier {
+
+    private ILanguageFactory languageFactory;
+    
+    public SubstringFunctionModifier(ILanguageFactory languageFactory) {
+    	this.languageFactory = languageFactory; 
+    }
+
+    @Override
+    public List<?> translate(IFunction function) {
+        List<IExpression> args = function.getParameters();
+        
+        if(args.size() == 2) {
+            args.add(languageFactory.createFunction(SourceSystemFunctions.LENGTH, Arrays.asList(args.get(0)), TypeFacility.RUNTIME_TYPES.INTEGER)); 
+        } 
+    	return null;
+    }
+    
+}
\ No newline at end of file


Property changes on: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SubstringFunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseCapabilities.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseCapabilities.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -45,8 +45,8 @@
     /**
      * @see com.metamatrix.data.ConnectorCapabilities#getSupportedFunctions()
      */
-    public List getSupportedFunctions() {
-        List supportedFunctions = new ArrayList();
+    public List<String> getSupportedFunctions() {
+        List<String> supportedFunctions = new ArrayList<String>();
         supportedFunctions.addAll(super.getSupportedFunctions());
         supportedFunctions.add("ABS"); //$NON-NLS-1$
         supportedFunctions.add("ACOS"); //$NON-NLS-1$
@@ -74,12 +74,11 @@
         supportedFunctions.add("CONCAT"); //$NON-NLS-1$
         supportedFunctions.add("||"); //$NON-NLS-1$
         supportedFunctions.add("LCASE"); //$NON-NLS-1$
-//      Remove support for LEFT (Case 2486).  Left is not supported by Sybase, found error when comparing
-//      to 3.1 version of capabilities class.  Problem found at ML during migration to 4.1        
-//        supportedFunctions.add("LEFT"); //$NON-NLS-1$
+        supportedFunctions.add("LEFT"); //$NON-NLS-1$
         supportedFunctions.add("LENGTH"); //$NON-NLS-1$
         supportedFunctions.add("LOWER"); //$NON-NLS-1$
         supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+        supportedFunctions.add("REPEAT"); //$NON-NLS-1$
         //supportedFunctions.add("RAND"); //$NON-NLS-1$
         supportedFunctions.add("RIGHT"); //$NON-NLS-1$
         supportedFunctions.add("RTRIM"); //$NON-NLS-1$
@@ -87,6 +86,23 @@
         supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
         supportedFunctions.add("UCASE"); //$NON-NLS-1$
         supportedFunctions.add("UPPER"); //$NON-NLS-1$
+        //supportedFunctons.add("CURDATE"); //$NON-NLS-1$
+        //supportedFunctons.add("CURTIME"); //$NON-NLS-1$
+        supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+        supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+        supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+        supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+        supportedFunctions.add("HOUR"); //$NON-NLS-1$
+        supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+        supportedFunctions.add("MONTH"); //$NON-NLS-1$
+        supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+        //supportedFunctions.add("NOW"); //$NON-NLS-1$
+        supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+        supportedFunctions.add("SECOND"); //$NON-NLS-1$
+        supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+        supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+        supportedFunctions.add("WEEK"); //$NON-NLS-1$
+        supportedFunctions.add("YEAR"); //$NON-NLS-1$
         supportedFunctions.add("CAST"); //$NON-NLS-1$
         supportedFunctions.add("CONVERT"); //$NON-NLS-1$
         supportedFunctions.add("IFNULL"); //$NON-NLS-1$
@@ -115,12 +131,4 @@
         return 50;
     }
     
-    /** 
-     * @see org.teiid.connector.basic.BasicConnectorCapabilities#supportsIntersect()
-     */
-    @Override
-    public boolean supportsIntersect() {
-        return true;
-    }
-
 }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,513 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.sybase;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-import org.teiid.connector.language.ILiteral;
-
-
-/**
- */
-public class SybaseConvertModifier extends BasicFunctionModifier {
-
-    private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
-    static {
-        // index of expressions in convert functions in Sybase is one, not zero
-        DROP_MODIFIER.setReplaceIndex(1);
-    }
-
-    private ILanguageFactory langFactory;
-    
-    public SybaseConvertModifier(ILanguageFactory langFactory) {
-        this.langFactory = langFactory;
-    }
-
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        IExpression modified = null;
-        
-        if (args.get(1) != null && args.get(1) instanceof ILiteral) {
-            String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
-            if (target.equals("string")) {  //$NON-NLS-1$ 
-                modified = convertToString(function);
-            } else if (target.equals("short")) {  //$NON-NLS-1$ 
-                modified = convertToShort(function);
-            } else if (target.equals("integer")) { //$NON-NLS-1$ 
-                modified = convertToInteger(function);
-            } else if (target.equals("long")) { //$NON-NLS-1$ 
-                modified = convertToLong(function);
-            } else if (target.equals("biginteger")) { //$NON-NLS-1$ 
-                modified = convertToBigInteger(function);
-            } else if (target.equals("float")) { //$NON-NLS-1$ 
-                modified = convertToFloat(function);
-            } else if (target.equals("double")) { //$NON-NLS-1$ 
-                modified = convertToDouble(function);
-            } else if (target.equals("bigdecimal")) { //$NON-NLS-1$ 
-                modified = convertToBigDecimal(function);
-            } else if (target.equals("date")) { //$NON-NLS-1$ 
-                modified = convertToDate(function);
-            } else if (target.equals("time")) { //$NON-NLS-1$ 
-                modified = convertToTime(function);
-            } else if (target.equals("timestamp")) { //$NON-NLS-1$ 
-                modified = convertToTimestamp(function);
-            } else if (target.equals("char")) { //$NON-NLS-1$ 
-                modified = convertToChar(function);
-            } else if (target.equals("boolean")) {  //$NON-NLS-1$ 
-                modified = convertToBoolean(function);
-            } else if (target.equals("byte")) {  //$NON-NLS-1$ 
-                modified = convertToByte(function);
-            } else {
-                modified = DROP_MODIFIER.modify(function);          
-            }
-            return modified;
-            
-        }
-        return DROP_MODIFIER.modify(function); 
-    }
-    
-    /* 
-     * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#translate(com.metamatrix.data.language.IFunction)
-     */
-    public List translate(IFunction function) {        
-        List parts = new ArrayList();
-        parts.add("convert("); //$NON-NLS-1$
-            
-        List<IExpression> args = function.getParameters();
-        
-        if(args != null && args.size() > 0) {
-            ILiteral type = (ILiteral) args.get(0);
-            String typeStr = type.getValue().toString();
-            
-            parts.add(typeStr);
-            
-            for(int i=1; i<args.size(); i++) {
-                parts.add(", "); //$NON-NLS-1$
-                parts.add(args.get(i));
-            }
-        }
-        parts.add(")"); //$NON-NLS-1$
-        return parts;
-    }
-    
-    private IExpression convertToBoolean(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-        
-        switch(srcCode) {
-            case STRING:
-                //TODO: how to map the 'true' to '1' before it is translated to bit
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "bit", Boolean.class); //$NON-NLS-1$      
-                break;                
-            default:
-                convert = DROP_MODIFIER.modify(function);
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToByte(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-        
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:
-            case SHORT: 
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:                     
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "tinyint", String.class);  //$NON-NLS-1$ 
-                break;  
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToString(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-        
-        switch(srcCode) { 
-            case CHAR:
-            case BOOLEAN:
-            case BYTE: 
-            case SHORT:
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:       
-                convert = createFunction(args.get(0), "varchar", String.class); //$NON-NLS-1$                                            
-                break;                        
-            case DATE: // convert(date, string) --> convert(varchar, date, 112) 
-                //TODO: what is the best format 111/110/101?
-                convert = createFunction(args.get(0), 101, String.class);
-                break;
-            case TIME: // convert(time, string) --> convert(varchar, time, 108)
-                convert = createFunction(args.get(0), 108, String.class);                        
-                break;
-            case TIMESTAMP:  // convert(time, string) --> convert(varchar, timestamp, 109)          
-                convert = createFunction(args.get(0), 109, String.class);                          
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function);
-                break;
-        }
-        
-        return convert;
-    }
-
-    private IExpression convertToShort(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN: 
-            case BYTE:    
-            case INTEGER:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "smallint", Short.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-        
-    private IExpression convertToInteger(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING: 
-            case BOOLEAN:       
-            case BYTE:
-            case SHORT:
-            case LONG:
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "int", Integer.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-      
-    private IExpression convertToLong(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:
-            case BYTE:
-            case SHORT:
-            case INTEGER:       
-            case BIGINTEGER:
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "numeric", Long.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToBigInteger(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:   
-            case FLOAT:
-            case DOUBLE:
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "numeric", java.math.BigInteger.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-
-    private IExpression convertToFloat(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:        
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:   
-            case BIGINTEGER:                                 
-            case DOUBLE: 
-            case BIGDECIMAL:
-                convert = createFunction(args.get(0), "real", Float.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }   
-       
-    private IExpression convertToDouble(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:      
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:   
-            case BIGINTEGER:                                 
-            case FLOAT:       
-            case BIGDECIMAL:   
-                convert = createFunction(args.get(0), "float", Double.class); //$NON-NLS-1$
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IExpression convertToBigDecimal(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class src = args.get(0).getType();
-        int srcCode = getSrcCode(src);
-
-        switch(srcCode) {
-            case STRING:
-            case BOOLEAN:         
-            case BYTE:
-            case SHORT:
-            case INTEGER:
-            case LONG:   
-            case BIGINTEGER:                                 
-            case FLOAT:       
-            case DOUBLE:
-                convert = createFunction(args.get(0), "float", java.math.BigDecimal.class); //$NON-NLS-1$
-                break;            
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-        
-    private IExpression convertToChar(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        return createFunction(args.get(0), "char", Character.class); //$NON-NLS-1$
-    } 
-             
-    private IExpression convertToDate(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        int srcCode = getSrcCode(srcType);
-
-        switch(srcCode) {
-            case STRING:
-                // convert(STRING, date) --> convert(datetime, STRING)
-                convert = createFunction(args.get(0), "datetime", java.sql.Date.class); //$NON-NLS-1$
-                break;
-            case TIMESTAMP:
-                // convert(TIMESTAMP, date) --> convert(datetime, convert(varchar, TIMESTAMP, 1/101))
-                // Build inner convert
-                IFunction innerConvert = langFactory.createFunction("convert",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        langFactory.createLiteral("varchar", String.class),  //$NON-NLS-1$
-                        args.get(0),
-                        langFactory.createLiteral(new Integer(109), Integer.class) ),
-                    String.class);
-                
-                // Build outer convert
-                convert = langFactory.createFunction("convert",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        langFactory.createLiteral("datetime", String.class),  //$NON-NLS-1$
-                        innerConvert ),
-                    java.sql.Timestamp.class);
-            
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-
-    private IExpression convertToTime(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        
-        int srcCode = getSrcCode(srcType);
-        switch(srcCode) {
-            case STRING:
-                //convert(STRING, time) --> convert(datetime, STRING)
-                convert = createFunction(args.get(0), "datetime", java.sql.Time.class); //$NON-NLS-1$
-                break;                                                                 
-            case TIMESTAMP:
-                // convert(TIMESTAMP, time) --> convert(datetime, convert(varchar, TIMESTAMP, 108/8) 
-                // Build inner convert
-                IFunction innerConvert = langFactory.createFunction("convert",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        langFactory.createLiteral("varchar", String.class),  //$NON-NLS-1$
-                        args.get(0),
-                        langFactory.createLiteral(new Integer(108), Integer.class) ),
-                    String.class);
-                    
-                // Build outer convert
-                convert = langFactory.createFunction("convert",  //$NON-NLS-1$
-                    Arrays.asList( 
-                        langFactory.createLiteral("datetime", String.class),  //$NON-NLS-1$
-                        innerConvert ),
-                    java.sql.Time.class);
-                                 
-                break;
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }    
-            
-    private IExpression convertToTimestamp(IFunction function) {
-        IExpression convert = null;
-        List<IExpression> args = function.getParameters();
-        Class srcType = args.get(0).getType();
-        int srcCode = getSrcCode(srcType);
-        switch(srcCode) {
-            case STRING:
-            case TIME:                
-            case DATE:
-                // convert(DATE/TIME/STRING, timestamp) --> convert(datetime, DATE)
-                convert = createFunction(args.get(0), "datetime", java.sql.Timestamp.class); //$NON-NLS-1$ 
-                    break;              
-            default:
-                convert = DROP_MODIFIER.modify(function); 
-                break;
-        }
-        
-        return convert;
-    }
-    
-    private IFunction createFunction(IExpression args0, String targetType, Class targetClass) {
-        IFunction created = langFactory.createFunction("convert", //$NON-NLS-1$
-            Arrays.asList(
-                langFactory.createLiteral(targetType, String.class),
-                args0), 
-                targetClass);
-        return created;            
-    }
-                
-    private IFunction createFunction(IExpression args0, int formatNumber, Class targetClass) {
-        IFunction created = langFactory.createFunction("convert",  //$NON-NLS-1$
-            Arrays.asList( langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$ 
-                args0,
-                langFactory.createLiteral(new Integer(formatNumber), Integer.class) ), 
-                targetClass);
-        return created;            
-    }
-        
-    private int getSrcCode(Class source) {
-        return ((Integer) typeMap.get(source)).intValue();
-    }
-
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,6 +25,7 @@
 package org.teiid.connector.jdbc.sybase;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.teiid.connector.api.ConnectorCapabilities;
@@ -33,9 +34,13 @@
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.jdbc.translator.AliasModifier;
-import org.teiid.connector.jdbc.translator.SubstringFunctionModifier;
+import org.teiid.connector.jdbc.translator.ConvertModifier;
+import org.teiid.connector.jdbc.translator.EscapeSyntaxModifier;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
+import org.teiid.connector.jdbc.translator.ModFunctionModifier;
 import org.teiid.connector.jdbc.translator.Translator;
 import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILimit;
 import org.teiid.connector.language.IOrderBy;
 import org.teiid.connector.language.IQueryCommand;
@@ -50,20 +55,102 @@
      */
     public void initialize(ConnectorEnvironment env) throws ConnectorException {
         super.initialize(env);
-        registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory())); 
+        registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory())); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("+")); //$NON-NLS-1$ 
         registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.LENGTH, new AliasModifier(getLengthFunctionName())); 
         registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull")); //$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier(getLanguageFactory(), getLengthFunctionName())); 
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new SybaseConvertModifier(getLanguageFactory()));      
+        registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$ 
+        registerFunctionModifier(SourceSystemFunctions.REPEAT, new AliasModifier("replicate")); //$NON-NLS-1$
+        registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier(getLanguageFactory()));
+        registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.LENGTH, new EscapeSyntaxModifier());
+        registerFunctionModifier(SourceSystemFunctions.ATAN2, new EscapeSyntaxModifier());
+        
+        //add in type conversion
+        ConvertModifier convertModifier = new ConvertModifier();
+        //boolean isn't treated as bit, since it doesn't support null
+        //byte is treated as smallint, since tinyint is unsigned
+    	convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(19,0)", FunctionModifier.LONG); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(38, 0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("numeric(38, 19)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("varchar(40)", FunctionModifier.STRING); //$NON-NLS-1$
+    	convertModifier.addTypeMapping("datetime", FunctionModifier.DATE, FunctionModifier.TIME, FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				List<Object> result = new ArrayList<Object>();
+				result.add("cast("); //$NON-NLS-1$
+				result.add("'1970-01-01 ' + "); //$NON-NLS-1$
+				result.addAll(convertTimeToString(function));
+				result.add(" AS datetime)"); //$NON-NLS-1$
+				return result;
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				List<Object> result = new ArrayList<Object>();
+				result.add("cast("); //$NON-NLS-1$
+				result.addAll(convertDateToString(function));
+				result.add(" AS datetime)"); //$NON-NLS-1$
+				return result;
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return convertTimeToString(function);
+			}
+		}); 
+    	convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return convertDateToString(function);
+			}
+		});
+    	convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				return convertTimestampToString(function);
+			}
+		});
+    	convertModifier.addNumericBooleanConversions();
+    	registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
     }
     
-    public String getLengthFunctionName() {
-    	return "char_length"; //$NON-NLS-1$
-    }
+	private List<Object> convertTimeToString(IFunction function) {
+		return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 8)"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
     
+    protected List<Object> convertDateToString(IFunction function) {
+		return Arrays.asList("stuff(stuff(convert(varchar, ", function.getParameters().get(0), ", 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+    
+    /**
+     * Written to only support version 15
+     * @param function
+     * @return
+     */
+	protected List<?> convertTimestampToString(IFunction function) {
+		return Arrays.asList("stuff(convert(varchar, ", function.getParameters().get(0), ", 123), 11, 1, ' ')"); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+    
     @Override
     public boolean useAsInGroupAlias() {
     	return false;
@@ -75,8 +162,8 @@
     }
     
     @Override
-    public String getDefaultTimeYMD() {
-    	return "1900-01-01"; //$NON-NLS-1$
+    public int getTimestampNanoPrecision() {
+    	return 3;
     }
     
     @Override

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/AliasModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/AliasModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/AliasModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -20,17 +20,15 @@
  * 02110-1301 USA.
  */
 
-/*
- */
 package org.teiid.connector.jdbc.translator;
 
+import java.util.List;
+
 import org.teiid.connector.language.*;
 
-/**
- */
-public class AliasModifier extends BasicFunctionModifier {
+public class AliasModifier extends FunctionModifier {
     // The alias to use
-    private String alias;
+    protected String alias;
         
     /**
      * Constructor that takes the alias to use for functions.
@@ -40,12 +38,14 @@
         this.alias = alias;    
     }
     
-    /**
-     * @see org.teiid.connector.jdbc.translator.FunctionModifier#modify(org.teiid.connector.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
-        function.setName(alias);
-        return function;
+    @Override
+    public List<?> translate(IFunction function) {
+    	modify(function);
+    	return null;
     }
 
+	protected void modify(IFunction function) {
+		function.setName(alias);
+	}
+    
 }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BasicFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BasicFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BasicFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.connector.jdbc.translator;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-
-
-/**
- */
-public abstract class BasicFunctionModifier implements FunctionModifier {
-
-    /*
-     * Public sharing part for the mapping between class and type in format of Map<class->Integer>.
-     */
-    public static final int STRING = 0;
-    public static final int CHAR = 1;
-    public static final int BOOLEAN = 2;
-    public static final int BYTE = 3;
-    public static final int SHORT = 4;
-    public static final int INTEGER = 5;
-    public static final int LONG = 6;
-    public static final int BIGINTEGER = 7;
-    public static final int FLOAT = 8;
-    public static final int DOUBLE = 9;
-    public static final int BIGDECIMAL = 10;
-    public static final int DATE = 11;
-    public static final int TIME = 12;
-    public static final int TIMESTAMP = 13;
-    public static final int OBJECT = 14;
-    public static final int BLOB = 15;
-    public static final int CLOB = 16;
-    public static final int XML = 17;
-
-    public static final Map typeMap = new HashMap();
-    
-    static {
-        typeMap.put(TypeFacility.RUNTIME_TYPES.STRING, new Integer(STRING));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.CHAR, new Integer(CHAR));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, new Integer(BOOLEAN));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.BYTE, new Integer(BYTE));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, new Integer(BIGINTEGER));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.OBJECT, new Integer(OBJECT));        
-        typeMap.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB));
-        typeMap.put(TypeFacility.RUNTIME_TYPES.XML, new Integer(XML));
-    }    
-    
-    /**
-     * Subclass should override this method as needed.
-     * @see org.teiid.connector.jdbc.translator.FunctionModifier#modify(org.teiid.connector.language.IFunction)
-     */
-    public IExpression modify(IFunction function) {
-        return function;
-    }
-
-    /**
-     * Subclass should override this method as needed.
-     * @see org.teiid.connector.jdbc.translator.FunctionModifier#translate(org.teiid.connector.language.IFunction)
-     */
-    public List<?> translate(IFunction function) {
-        return null;
-    }
-
-}

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BindValueVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BindValueVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/BindValueVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExistsCriteria;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISetClause;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.visitor.framework.HierarchyVisitor;
-
-/**
- * This visitor will mark literals in well known locations as bindValues.
- * These values will be put in the generated SQL as ? 
- * and have the corresponding value set on the PreparedStatement 
- */
-final class BindValueVisitor extends HierarchyVisitor {
-
-    private boolean replaceWithBinding = false;
-
-    public void visit(IInlineView obj) {
-        replaceWithBinding = false;
-        visitNode(obj.getQuery());
-    }
-
-    public void visit(IScalarSubquery obj) {
-        replaceWithBinding = false;
-        super.visit(obj);
-    }
-
-    public void visit(IExistsCriteria obj) {
-        replaceWithBinding = false;
-        super.visit(obj);
-    }
-
-    public void visit(ISubqueryCompareCriteria obj) {
-        replaceWithBinding = false;
-        super.visit(obj);
-    }
-
-    /**
-     * In general it is not appropriate to use bind values within a function
-     * unless the particulars of the function parameters are know.  
-     * As needed, other visitors or modifiers can set the literals used within
-     * a particular function as bind variables.  
-     */
-    public void visit(IFunction obj) {
-        replaceWithBinding = false;
-        super.visit(obj);
-    }
-
-    public void visit(IInCriteria obj) {
-        replaceWithBinding = true;
-        visitNodes(obj.getRightExpressions());
-    }
-
-    public void visit(ILikeCriteria obj) {
-        replaceWithBinding = true;
-        visitNode(obj.getRightExpression());
-    }
-
-    /**
-     * Note that this will only visit the right expression.  In general most compares
-     * involving literals will be something like element = literal (this is enforced as
-     * much as possible by the QueryRewriter).  In rare circumstances, it is possible to
-     * have literal = literal (most notably null <> null).  Using bind variables on
-     * both sides of the operator is not supported by most databases.
-     */
-    public void visit(ICompareCriteria obj) {
-        replaceWithBinding = true;
-        visitNode(obj.getRightExpression());
-    }
-
-    /**
-     * Will look for bind values in the when criteria.
-     * The actual restriction for case statements seems to be that at least one branch must
-     * not contain a bind variable.
-     */
-    public void visit(ISearchedCaseExpression obj) {
-        for (int i = 0; i < obj.getWhenCount(); i++) {
-            visitNode(obj.getWhenCriteria(i));
-        }
-    }
-
-    @Override
-    public void visit(IInsertExpressionValueSource obj) {
-        replaceWithBinding = true;
-        visitNodes(obj.getValues());
-    }
-    
-    @Override
-    public void visit(ISetClause obj) {
-        replaceWithBinding = true;
-        visitNode(obj.getValue());
-    }
-
-    public void visit(ILiteral obj) {
-        if (replaceWithBinding || TranslatedCommand.isBindEligible(obj)) {
-            obj.setBindValue(true);
-        }
-    }
-    
-    public void visitNode(ILanguageObject obj) {
-        boolean replacementMode = replaceWithBinding;
-        super.visitNode(obj);
-        this.replaceWithBinding = replacementMode;
-    }
-}
\ No newline at end of file

Added: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ConvertModifier.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.translator;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+import org.teiid.connector.language.ILiteral;
+
+/**
+ * Base class for handling the convert function.
+ * <p>Convert is by far the most complicated pushdown function since it actually 
+ * represents a matrix of possible functions. Additionally not every source supports
+ * the same semantics as our conversions.</p>
+ * <p>Each instance of this class makes a best effort at handling converts for for a 
+ * given source - compensating for differing string representation, the lack a time type
+ * etc. 
+ * <p>The choice of conversion logic is as follows:
+ * <ul>
+ *  <li>Look for a specific conversion between the source and target - {@link #addConvert(int, int, FunctionModifier)}</li>
+ *  <li>Filter common implicit conversions</li>
+ *  <li>Look for a general source conversion - {@link #addSourceConversion(FunctionModifier, int...)}</li>
+ *  <li>Look for a general target conversion - {@link #addTypeConversion(FunctionModifier, int...)}</li>
+ *  <li>Look for a type mapping, which will replace the target type with the given native type - {@link #addTypeMapping(String, int...)}</li>
+ *  <li>Drop the conversion</li>
+ * </ul>
+ */
+public class ConvertModifier extends FunctionModifier {
+	
+	public static class FormatModifier extends AliasModifier {
+		
+		private String format;
+		
+		public FormatModifier(String alias) {
+			super(alias);
+		}
+		
+		public FormatModifier(String alias, String format) {
+			super(alias);
+			this.format = format;
+		}
+
+		@Override
+		public List<?> translate(IFunction function) {
+			modify(function);
+			if (format == null) {
+				function.getParameters().remove(1);
+			} else {
+				((ILiteral)function.getParameters().get(1)).setValue(format);
+			}
+			return null;
+		}
+		
+	}
+
+    private Map<Integer, String> typeMapping = new HashMap<Integer, String>();
+    private Map<Integer, FunctionModifier> typeModifier = new HashMap<Integer, FunctionModifier>();
+    private Map<Integer, FunctionModifier> sourceModifier = new HashMap<Integer, FunctionModifier>();
+    private Map<List<Integer>, FunctionModifier> specificConverts = new HashMap<List<Integer>, FunctionModifier>();
+    private boolean booleanNumeric;
+    private boolean wideningNumericImplicit;
+    
+    public void addTypeConversion(FunctionModifier convert, int ... targetType) {
+    	for (int i : targetType) {
+        	this.typeModifier.put(i, convert);
+		}
+    }
+    
+    public void addSourceConversion(FunctionModifier convert, int ... sourceType) {
+    	for (int i : sourceType) {
+        	this.sourceModifier.put(i, convert);
+		}
+    }
+    
+    public void addTypeMapping(String nativeType, int ... targetType) {
+    	for (int i : targetType) {
+    		typeMapping.put(i, nativeType);
+    	}
+    }
+    
+    public void setWideningNumericImplicit(boolean wideningNumericImplicit) {
+		this.wideningNumericImplicit = wideningNumericImplicit;
+	}
+        
+    public void addConvert(int sourceType, int targetType, FunctionModifier convert) {
+    	specificConverts.put(Arrays.asList(sourceType, targetType), convert);
+    }
+    
+    @Override
+    public List<?> translate(IFunction function) {
+    	function.setName("cast"); //$NON-NLS-1$
+    	int targetCode = getCode(function.getType());
+    	List<IExpression> args = function.getParameters();
+        Class<?> srcType = args.get(0).getType();
+        int sourceCode = getCode(srcType);
+        
+		List<Integer> convesionCode = Arrays.asList(sourceCode, targetCode);
+		FunctionModifier convert = specificConverts.get(convesionCode);
+		if (convert != null) {
+			return convert.translate(function);
+		}
+
+		boolean implicit = sourceCode == CHAR && targetCode == STRING;
+
+		if (targetCode >= BYTE && targetCode <= BIGDECIMAL) {
+			if (booleanNumeric && sourceCode == BOOLEAN) {
+				sourceCode = BYTE;
+				implicit = targetCode == BYTE;
+			}
+			implicit |= wideningNumericImplicit && sourceCode >= BYTE && sourceCode <= BIGDECIMAL && sourceCode < targetCode;
+		}
+		
+		if (!implicit) {
+			convert = this.sourceModifier.get(sourceCode);
+			if (convert != null
+					 && (!convert.equals(sourceModifier.get(targetCode)) || sourceCode == targetCode)) { //checks for implicit, but allows for dummy converts
+				return convert.translate(function);
+			}
+			
+			convert = this.typeModifier.get(targetCode);
+			if (convert != null
+					 && (!convert.equals(typeModifier.get(sourceCode)) || sourceCode == targetCode)) { //checks for implicit, but allows for dummy converts
+				return convert.translate(function);
+			}
+	    	
+	    	String type = typeMapping.get(targetCode);
+	    	
+	    	if (type != null 
+	    			&& (!type.equals(typeMapping.get(sourceCode)) || sourceCode == targetCode)) { //checks for implicit, but allows for dummy converts 
+	    		((ILiteral)function.getParameters().get(1)).setValue(type);
+	    		return null;
+	    	}
+		}
+    	
+    	return Arrays.asList(function.getParameters().get(0));
+	}
+
+	public static IFunction createConvertFunction(ILanguageFactory langFactory, IExpression expr, String typeName) {
+		Class<?> type = TypeFacility.getDataTypeClass(typeName);
+		return langFactory.createFunction(SourceSystemFunctions.CONVERT, 
+				new IExpression[] {expr, langFactory.createLiteral(typeName, type)}, type);
+	}
+	
+	public void addNumericBooleanConversions() {
+		this.booleanNumeric = true;
+		//number -> boolean
+		this.addTypeConversion(new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				IExpression stringValue = function.getParameters().get(0);
+				return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN 0 WHEN ", stringValue, " IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		}, FunctionModifier.BOOLEAN);
+		this.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				IExpression stringValue = function.getParameters().get(0);
+				return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN 'false' WHEN ", stringValue, " IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		});
+    	this.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new FunctionModifier() {
+			@Override
+			public List<?> translate(IFunction function) {
+				IExpression stringValue = function.getParameters().get(0);
+				return Arrays.asList("CASE WHEN ", stringValue, " IN ('false', '0') THEN 0 WHEN ", stringValue, " IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+		});
+	}
+
+}


Property changes on: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ConvertModifier.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/DropFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/DropFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/DropFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import java.util.List;
-
-import org.teiid.connector.jdbc.JDBCPlugin;
-import org.teiid.connector.language.*;
-
-
-/**
- * This FunctionModifier will cause this function to be dropped by replacing the function
- * with (by default) the first argument of the function.  Optionally, the replacement index 
- * can be overridden.  This modifier should only be used with functions having the
- * minimum or more number of arguments. 
- */
-public class DropFunctionModifier extends BasicFunctionModifier {
-
-    private int replaceIndex = 0;
-    
-    public void setReplaceIndex(int index) {
-        this.replaceIndex = index;
-    }
-    
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        if(args.size() <= replaceIndex) { 
-            throw new IllegalArgumentException(JDBCPlugin.Util.getString("DropFunctionModifier.DropFunctionModifier_can_only_be_used_on_functions_with___1") + function); //$NON-NLS-1$
-        }
-
-        return args.get(replaceIndex);
-    }
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/EscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/EscapeSyntaxModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/EscapeSyntaxModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -33,18 +33,14 @@
  * driver can then convert to the correct database syntax for us. 
  * @since 5.0
  */
-public class EscapeSyntaxModifier extends BasicFunctionModifier {
+public class EscapeSyntaxModifier extends FunctionModifier {
 
-    public EscapeSyntaxModifier() {
-        super();
-    }
-    
     /** 
      * @see org.teiid.connector.jdbc.translator.BasicFunctionModifier#translate(org.teiid.connector.language.IFunction)
      * @since 5.0
      */
-    public List translate(IFunction function) {
-    	List objs = new ArrayList();
+    public List<?> translate(IFunction function) {
+    	List<Object> objs = new ArrayList<Object>();
         objs.add("{fn "); //$NON-NLS-1$
         objs.add(function);
         objs.add("}"); //$NON-NLS-1$

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ExtractFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ExtractFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -37,7 +37,7 @@
  * Convert the YEAR/MONTH/DAY etc. function into an equivalent Extract function.  
  * Format: EXTRACT(YEAR from Element) or EXTRACT(YEAR from DATE '2004-03-03')
  */
-public class ExtractFunctionModifier extends BasicFunctionModifier {
+public class ExtractFunctionModifier extends FunctionModifier {
 	public static final String YEAR = "YEAR"; //$NON-NLS-1$
 	public static final String QUARTER = "QUARTER"; //$NON-NLS-1$
 	public static final String MONTH = "MONTH"; //$NON-NLS-1$

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/FunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/FunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -24,29 +24,71 @@
  */
 package org.teiid.connector.jdbc.translator;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-import org.teiid.connector.language.IExpression;
+import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageObject;
 
 
 /**
- * Implementations of this interface are used to modify metamatrix functions
+ * Implementations of this interface are used to modify Teiid functions
  * coming in to the connector into alternate datasource-specific language, if
  * necessary. 
  */
-public interface FunctionModifier {
-    
-    /**
-     * Takes an IFunction and returns the datasource-specific IExpression,
-     * or can possibly return the unmodified function parameter itself. 
-     * @param function
-     * @return IExpression or unmodified function
-     * @since 4.2
+public abstract class FunctionModifier {
+	
+    /*
+     * Public sharing part for the mapping between class and type in format of Map<class->Integer>.
      */
-    IExpression modify(IFunction function);
+    public static final int STRING = 0;
+    public static final int CHAR = 1;
+    public static final int BOOLEAN = 2;
+    public static final int BYTE = 3;
+    public static final int SHORT = 4;
+    public static final int INTEGER = 5;
+    public static final int LONG = 6;
+    public static final int BIGINTEGER = 7;
+    public static final int FLOAT = 8;
+    public static final int DOUBLE = 9;
+    public static final int BIGDECIMAL = 10;
+    public static final int DATE = 11;
+    public static final int TIME = 12;
+    public static final int TIMESTAMP = 13;
+    public static final int OBJECT = 14;
+    public static final int BLOB = 15;
+    public static final int CLOB = 16;
+    public static final int XML = 17;
+
+    private static final Map<Class<?>, Integer> typeMap = new HashMap<Class<?>, Integer>();
     
+    static {
+        typeMap.put(TypeFacility.RUNTIME_TYPES.STRING, new Integer(STRING));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.CHAR, new Integer(CHAR));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, new Integer(BOOLEAN));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.BYTE, new Integer(BYTE));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, new Integer(BIGINTEGER));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.OBJECT, new Integer(OBJECT));        
+        typeMap.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB));
+        typeMap.put(TypeFacility.RUNTIME_TYPES.XML, new Integer(XML));
+    }    
+    
+    public static int getCode(Class<?> source) {
+        return typeMap.get(source).intValue();
+    }
+    
     /**
      * Return a List of translated parts ({@link ILanguageObject}s and Objects), or null
      * if this FunctionModifier wishes to rely on the default translation of the
@@ -55,5 +97,6 @@
      * @return List of translated parts, or null
      * @since 4.2
      */
-    List<?> translate(IFunction function);
+    public abstract List<?> translate(IFunction function);
+    
 }

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/LocateFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/LocateFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -69,12 +69,11 @@
  * 
  * @since 6.2
  */
-public class LocateFunctionModifier extends BasicFunctionModifier {
+public class LocateFunctionModifier extends AliasModifier {
 
 	public static String LOCATE = "LOCATE"; //$NON-NLS-1$
 	
     private ILanguageFactory langFactory;
-    private String functionName = LOCATE;
     private boolean sourceStringFirst;
     
 	/**
@@ -98,8 +97,8 @@
 	 * @param sourceStringFirst
 	 */
     public LocateFunctionModifier(ILanguageFactory langFactory, final String functionName, boolean sourceStringFirst) {
+    	super(functionName);
     	this.langFactory = langFactory;
-    	this.functionName = functionName;
     	this.sourceStringFirst = sourceStringFirst;
     }
 
@@ -142,8 +141,8 @@
 	 * 
 	 * @param function the LOCATE function that may need to be modified
 	 */
-    public IExpression modify(IFunction function) {
-    	function.setName(this.functionName);
+    public void modify(IFunction function) {
+    	super.modify(function);
         List<IExpression> args = function.getParameters();
         IExpression searchStr = args.get(0);
         IExpression sourceStr = args.get(1);
@@ -156,7 +155,6 @@
 			args.set(0, sourceStr);
 			args.set(1, searchStr);
         }
-        return function;
     }
 
 	private IExpression ensurePositiveStartIndex(IExpression startIndex) {

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,185 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.api.TypeFacility.RUNTIME_TYPES;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-/**
- * A modifier class that can be used to translate the scalar function 
- * <code>mod(x, y)</code> to a function or expression that can be used at the 
- * data source.
- * <p>
- * If the default implementation is used, a function name of MOD will be used 
- * for the alias name and the expression will be unmodified if the data type 
- * of the <code>x</code> parameter is one of {@link RUNTIME_TYPES#BYTE}, 
- * {@link RUNTIME_TYPES#SHORT}, {@link RUNTIME_TYPES#INTEGER}, or 
- * {@link RUNTIME_TYPES#LONG}.  If the data type is not one of these types, the
- * expression will be modified to return: <code>(x - (TRUNC((x / y), 0) * y))</code>
- * 
- * @since 6.2
- */
-public class ModFunctionModifier extends AliasModifier {
-
-	private static List<Class<?>> DEFAULT_TYPELIST = new ArrayList<Class<?>>(4);
-	static {
-		DEFAULT_TYPELIST.add(RUNTIME_TYPES.BYTE);
-		DEFAULT_TYPELIST.add(RUNTIME_TYPES.SHORT);
-		DEFAULT_TYPELIST.add(RUNTIME_TYPES.INTEGER);
-		DEFAULT_TYPELIST.add(RUNTIME_TYPES.LONG);
-	}
-	private static String DEFAULT_FUNCTIONNAME = "MOD"; //$NON-NLS-1$
-
-	private ILanguageFactory langFactory;
-	private List<Class<?>> supTypeList;
-    
-	/**
-	 * Constructs a {@link AliasModifier} object that can be used to translate 
-	 * the use of the scalar function MOD() to a source specific scalar function 
-	 * or expression.
-	 * <p>
-	 * This constructor invokes {@link #MODFunctionModifier(ILanguageFactory, String, List)}
-	 * passing it <code>langFactory</code>, {@link #DEFAULT_FUNCTIONNAME}, and 
-	 * {@link #DEFAULT_TYPELIST}.
-	 * 
-	 * @param langFactory the language factory associated with translation
-	 */
-    public ModFunctionModifier(ILanguageFactory langFactory) {
-    	this(langFactory, DEFAULT_FUNCTIONNAME, DEFAULT_TYPELIST);
-    }
-	
-    /**
-	 * Constructs a {@link AliasModifier} object that can be used to translate 
-	 * the use of the scalar function MOD() to a source specific scalar function 
-	 * or expression.
-	 * <p>
-	 * <code>functionName</code> is used to construct the parent {@link AliasModifier}
-	 * and should represent the default function name or alias used by the data 
-	 * source.
-	 * <p>
-	 * <code>supportedTypeList</code> should contain a list of <code>Class</code> 
-	 * objects that represent the data types that the data source can support  
-	 * with its implementation of the MOD() scalar function.  
-     * 
-     * @param langFactory the language factory associated with translation
-     * @param functionName the function name or alias that should be used 
-     *                     instead of MOD
-     * @param supportedTypeList a list of type classes that is supported by the 
-     *                          data source's MOD function
-     */
-    public ModFunctionModifier(ILanguageFactory langFactory, String functionName, List<Class<?>>supportedTypeList) {
-    	super(functionName);
-        this.langFactory = langFactory;
-        if ( supportedTypeList != null ) {
-        	this.supTypeList = supportedTypeList;
-        } else {
-        	this.supTypeList = ModFunctionModifier.DEFAULT_TYPELIST;
-        }
-    }
-	
-	/**
-	 * Returns a version of <code>function</code> suitable for executing at the 
-	 * data source.
-	 * <p>
-	 * If the data type of the parameters in <code>function</code> is in the 
-	 * list of supported data types, this method simply returns <code>super.modify(function)</code>.
-	 * <p>
-	 * If the data type of the parameters in <code>function</code are not in the 
-	 * list of supported data types, this method will return an expression that 
-	 * is valid at the data source and will yield the same result as the original 
-	 * MOD() scalar function.  To build the expression, a call is make to 
-	 * {@link #getQuotientExpression(IExpression)} and its result is multiplied 
-	 * by the second parameter of <code>function</code> and that result is then 
-	 * subtracted from the first parameter of <code>function</code>.
-	 * <p>
-	 * For example:
-	 * <code>mod(x, y)  --->  (x - (getQuotientExpression((x / y)) * y))</code>
-	 * 
-	 * @param function the MOD function that may need to be modified
-	 * @see org.teiid.connector.jdbc.translator.AliasModifier#modify(org.teiid.connector.language.IFunction)
-	 */
-	@Override
-	public IExpression modify(IFunction function) {
-		List<IExpression> expressions = function.getParameters();
-		IExpression dividend = expressions.get(0);
-		IExpression divisor = expressions.get(1);
-
-		// Check to see if parameters are supported by source MOD function
-		if (this.supTypeList.contains(dividend.getType())) {
-			return super.modify(function);
-		}
-
-		/* 
-		 * Parameters are not supported by source MOD function so modify 
-		 * MOD(<dividend>, <divisor>)  -->  (<dividend> - (<func_getQuotient((<dividend> / <divisor>))> * <divisor>))
-		 */
-		// -->   (<dividend> / <divisor>)
-		IFunction divide = langFactory.createFunction("/", Arrays.asList(dividend, divisor), dividend.getType()); //$NON-NLS-1$
-		// -->   <func_getQuotient(<divide>)>  -- i.e. TRUNC(<divide>, 0)
-		IFunction quotient = (IFunction) this.getQuotientExpression(divide);
-		// -->   (<quotient> * <divisor>)
-		List<IExpression> multiplyArgs = Arrays.asList(quotient, divisor);
-		IFunction multiply = langFactory.createFunction("*", multiplyArgs, divisor.getType()); //$NON-NLS-1$
-		// -->   (<dividend> - <multiply>)
-		List<IExpression> minusArgs = Arrays.asList(dividend, multiply);
-		return langFactory.createFunction("-", minusArgs, dividend.getType()); //$NON-NLS-1$
-	}
-
-	/**
-	 * Return an expression that will result in the quotient of </code>division</code>. 
-	 * Quotient should always be represented as an integer (no remainder).
-	 * <p>
-	 * <code>division</code> will represent simple division that may result in a
-	 * fraction.  <code>division</code> should be returned within a helper 
-	 * function or expression that will result in an integer return value (no 
-	 * decimal or fraction).
-	 * <p>
-	 * If this method is not overriden, the result will be:
-	 * <p>
-	 * <ul>TRUNC(<code>division</code>, 0)</ul>
-	 * <p>
-	 * For the default TRUNC() function to work, the source must support it.  
-	 * TRUNC was used instead of FLOOR because FLOOR rounds to the nearest
-	 * integer toward negative infinity.  This would result in incorrect values 
-	 * when performing MOD on negative float, double, etc. values.
-	 *   
-	 * @param division an expression representing simple division
-	 * @return an expression that will extract the quotient from the 
-	 *         <code>division</code> expression
-	 */
-	protected IExpression getQuotientExpression(IExpression division) {
-		// -->   TRUNC(<division>, 0)
-		return langFactory.createFunction("TRUNC", Arrays.asList(division, langFactory.createLiteral(0, RUNTIME_TYPES.SHORT)), division.getType()); //$NON-NLS-1$
-	}
-
-	protected ILanguageFactory getLanguageFactory() {
-		return this.langFactory;
-	}
-	
-}

Copied: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java (from rev 1276, trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/ModFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.translator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+/**
+ * Adds mod (remainder) support for non-integral types
+ */
+public class ModFunctionModifier extends AliasModifier {
+
+	private static Set<Class> SUPPORTED_TYPES = new HashSet<Class>(Arrays.asList(TypeFacility.RUNTIME_TYPES.INTEGER, TypeFacility.RUNTIME_TYPES.LONG));
+
+	private ILanguageFactory langFactory;
+    
+    public ModFunctionModifier(String modFunction, ILanguageFactory langFactory) {
+    	super(modFunction);
+        this.langFactory = langFactory;
+    }
+    
+    @Override
+    public List<?> translate(IFunction function) {
+    	List<IExpression> expressions = function.getParameters();
+		Class<?> type = function.getType();
+		if (SUPPORTED_TYPES.contains(type)) {
+			modify(function);
+			return null;
+		}
+		//x % y => x - sign(x) * floor(abs(x / y)) * y
+		IFunction divide = langFactory.createFunction(SourceSystemFunctions.DIVIDE_OP, new ArrayList<IExpression>(expressions), type); 
+
+		IFunction abs = langFactory.createFunction(SourceSystemFunctions.ABS, Arrays.asList(divide), type);
+		
+		IFunction floor = langFactory.createFunction(SourceSystemFunctions.FLOOR, Arrays.asList(abs), type); 
+		
+		IFunction sign = langFactory.createFunction(SourceSystemFunctions.SIGN, Arrays.asList(expressions.get(0)), type);
+		
+		List<? extends IExpression> multArgs = Arrays.asList(sign, floor, langFactory.createFunction(SourceSystemFunctions.ABS, Arrays.asList(expressions.get(1)), type));
+		IFunction mult = langFactory.createFunction(SourceSystemFunctions.MULTIPLY_OP, multArgs, type); 
+
+		List<IExpression> minusArgs = Arrays.asList(expressions.get(0), mult);
+		
+		return Arrays.asList(langFactory.createFunction(SourceSystemFunctions.SUBTRACT_OP, minusArgs, type)); 
+	}
+	
+}

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ReplacementVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ReplacementVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ReplacementVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,220 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.IAggregate;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.IGroupBy;
-import org.teiid.connector.language.IInCriteria;
-import org.teiid.connector.language.IInlineView;
-import org.teiid.connector.language.IInsertExpressionValueSource;
-import org.teiid.connector.language.IIsNullCriteria;
-import org.teiid.connector.language.ILikeCriteria;
-import org.teiid.connector.language.IQueryCommand;
-import org.teiid.connector.language.IScalarSubquery;
-import org.teiid.connector.language.ISearchedCaseExpression;
-import org.teiid.connector.language.ISelectSymbol;
-import org.teiid.connector.language.ISubqueryCompareCriteria;
-import org.teiid.connector.language.ISubqueryInCriteria;
-import org.teiid.connector.visitor.framework.AbstractLanguageVisitor;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-/**
- */
-public class ReplacementVisitor extends AbstractLanguageVisitor {
-
-    private Translator translator;  
-    private Map<String, FunctionModifier> functionModifiers;
-    private ExecutionContext context;
-
-    /**
-     * Set the functon modifiers.  
-     * @param Map of function names to function modifiers.
-     */
-    public ReplacementVisitor(ExecutionContext context, Translator translator){
-        this.translator = translator;
-        this.functionModifiers = translator.getFunctionModifiers();
-        this.context = context;
-    }
-            
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IAggregate)
-     */
-    public void visit(IAggregate obj) {
-        obj.setExpression(replaceFunction(obj.getExpression()));
-    }
-    
-    public void visit(IInlineView obj) {
-    	try {
-			obj.setQuery((IQueryCommand)translator.modifyCommand(obj.getQuery(), context));
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICompareCriteria)
-     */
-    public void visit(ICompareCriteria obj) {
-        obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
-        obj.setRightExpression(replaceFunction(obj.getRightExpression()));
-    }
-
-    /**
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IFunction)
-     */
-    public void visit(IFunction obj) {
-        List<IExpression> args = obj.getParameters();
-        for(int i=0; i<args.size(); i++) {
-            args.set(i, replaceFunction(args.get(i)));
-        }
-    }    
-    
-    /** 
-     * @see org.teiid.connector.visitor.framework.HierarchyVisitor#visit(org.teiid.connector.language.IGroupBy)
-     * @since 4.3
-     */
-    public void visit(IGroupBy obj) {
-        List<IExpression> expressions = obj.getElements();
-        
-        for (int i=0; i<expressions.size(); i++) {
-            IExpression expression = expressions.get(i);
-            expressions.set(i, replaceFunction(expression));
-        }
-    }      
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IInCriteria)
-     */
-    public void visit(IInCriteria obj) {
-        obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
-        List<IExpression> rightExprs = obj.getRightExpressions();
-        
-        for(int i=0; i<rightExprs.size(); i++) {
-            IExpression expr = rightExprs.get(i);
-            rightExprs.set(i, replaceFunction(expr));
-        }
-    }
-    
-    @Override
-    public void visit(IInsertExpressionValueSource obj) {
-        List<IExpression> values = obj.getValues();
-        
-        for(int i=0; i<values.size(); i++) {
-            IExpression expr = values.get(i);
-            values.set(i, replaceFunction(expr));
-        }
-    }
-    
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IIsNullCriteria)
-     */
-    public void visit(IIsNullCriteria obj) {
-        obj.setExpression(replaceFunction(obj.getExpression()));
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ILikeCriteria)
-     */
-    public void visit(ILikeCriteria obj) {
-        obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
-        obj.setRightExpression(replaceFunction(obj.getRightExpression()));
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISearchedCaseExpression)
-     */
-    public void visit(ISearchedCaseExpression obj) {
-        int whenCount = obj.getWhenCount();
-        for(int i=0; i<whenCount; i++) {
-            obj.setThenExpression(i, replaceFunction(obj.getThenExpression(i)));
-        }
-        obj.setElseExpression(replaceFunction(obj.getElseExpression()));
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISelectSymbol)
-     */
-    public void visit(ISelectSymbol obj) {
-        obj.setExpression(replaceFunction(obj.getExpression()));
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryCompareCriteria)
-     */
-    public void visit(ISubqueryCompareCriteria obj) {
-        try {
-			obj.setQuery((IQueryCommand)translator.modifyCommand(obj.getQuery(), context));
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-    	obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
-    }
-    
-    @Override
-    public void visit(IScalarSubquery obj) {
-    	try {
-			obj.setQuery((IQueryCommand)translator.modifyCommand(obj.getQuery(), context));
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-    }
-
-    /* 
-     * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ISubqueryInCriteria)
-     */
-    public void visit(ISubqueryInCriteria obj) {
-    	try {
-			obj.setQuery((IQueryCommand)translator.modifyCommand(obj.getQuery(), context));
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e);
-		}
-        obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
-    }
-         
-    private IExpression replaceFunction(IExpression expression) {
-        if(functionModifiers != null && expression != null && expression instanceof IFunction){
-            // Look for function modifier
-            IFunction function = (IFunction) expression;
-            String key = function.getName().toLowerCase();        
-            if(functionModifiers.containsKey(key)) {
-                FunctionModifier modifier = functionModifiers.get(key);
-                
-                // Modify function and return it
-                return modifier.modify(function);                                        
-            }
-        } 
-        
-        // Fall through and return original expression        
-        return expression;
-    }    
-    
-}

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -32,31 +32,33 @@
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.jdbc.translator.Translator.NullOrder;
 import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.ICompareCriteria;
 import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.IInCriteria;
+import org.teiid.connector.language.IInsertExpressionValueSource;
 import org.teiid.connector.language.ILanguageObject;
-import org.teiid.connector.language.ILimit;
+import org.teiid.connector.language.ILikeCriteria;
 import org.teiid.connector.language.ILiteral;
 import org.teiid.connector.language.IOrderByItem;
 import org.teiid.connector.language.IParameter;
 import org.teiid.connector.language.IProcedure;
+import org.teiid.connector.language.ISearchedCaseExpression;
+import org.teiid.connector.language.ISelectSymbol;
+import org.teiid.connector.language.ISetClause;
 import org.teiid.connector.language.IParameter.Direction;
 import org.teiid.connector.language.ISetQuery.Operation;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
 import org.teiid.connector.visitor.util.SQLStringVisitor;
 
 
 /**
  * This visitor takes an ICommand and does DBMS-specific conversion on it
  * to produce a SQL String.  This class is expected to be subclassed.
- * Specialized instances of this class can be gotten from a SQL Translator
- * {@link Translator#getTranslationVisitor(RuntimeMetadata) using this method}.
  */
 public class SQLConversionVisitor extends SQLStringVisitor{
 
@@ -74,6 +76,8 @@
     
     private Set<ILanguageObject> recursionObjects = Collections.newSetFromMap(new IdentityHashMap<ILanguageObject, Boolean>());
     
+    private boolean replaceWithBinding = false;
+    
     public SQLConversionVisitor(Translator translator) {
         this.translator = translator;
         this.prepared = translator.usePreparedStatements();
@@ -81,47 +85,36 @@
     
     @Override
     public void append(ILanguageObject obj) {
-    	if ((obj instanceof IFunction || obj instanceof ICommand || obj instanceof ILimit) && !recursionObjects.contains(obj)) {
-	    	recursionObjects.add(obj);
-	    	try {
-	    		List<?> parts = null;
-    	    	if (obj instanceof IFunction) {
-    	    		IFunction function = (IFunction)obj;
-    	    		Map<String, FunctionModifier> functionModifiers = translator.getFunctionModifiers();
-    	    		if (functionModifiers != null) {
-    	    			FunctionModifier modifier = functionModifiers.get(function.getName().toLowerCase());
-    	    			if (modifier != null) {
-    	    				parts = modifier.translate(function);
-    	    			}
-    	    		}
-    	    	} else if (obj instanceof ICommand) {
-    	    		parts = translator.translateCommand((ICommand)obj, context);
-    	    	} else if (obj instanceof ILimit) {
-    	    		parts = translator.translateLimit((ILimit)obj, context);
-    	    	}
-	    		if (parts != null) {
-	    			this.appendParts(parts);
-	    			return;
-	    		}
-	    	} finally {
-	    		recursionObjects.remove(obj);
-	    	}
-    	} 
-    	super.append(obj);
+        boolean replacementMode = replaceWithBinding;
+        if (obj instanceof ICommand || obj instanceof IFunction) {
+    	    /*
+    	     * In general it is not appropriate to use bind values within a function
+    	     * unless the particulars of the function parameters are know.  
+    	     * As needed, other visitors or modifiers can set the literals used within
+    	     * a particular function as bind variables.  
+    	     */
+        	this.replaceWithBinding = false;
+        }
+    	List<?> parts = null;
+    	if (!recursionObjects.contains(obj)) {
+    		parts = translator.translate(obj, context);
+    	}
+		if (parts != null) {
+			recursionObjects.add(obj);
+			for (Object part : parts) {
+			    if(part instanceof ILanguageObject) {
+			        append((ILanguageObject)part);
+			    } else {
+			        buffer.append(part);
+			    }
+			}
+			recursionObjects.remove(obj);
+		} else {
+			super.append(obj);
+		}
+        this.replaceWithBinding = replacementMode;
     }
     
-	private void appendParts(List parts) {
-		Iterator iter = parts.iterator();
-		while(iter.hasNext()) {
-		    Object part = iter.next();
-		    if(part instanceof ILanguageObject) {
-		        append((ILanguageObject)part);
-		    } else {
-		        buffer.append(part);
-		    }
-		}
-	}
-	
 	@Override
 	public void visit(IOrderByItem obj) {
 		super.visit(obj);
@@ -203,14 +196,56 @@
      * @see org.teiid.connector.visitor.util.SQLStringVisitor#visit(org.teiid.connector.language.ILiteral)
      */
     public void visit(ILiteral obj) {
-        if (this.prepared && obj.isBindValue()) {
+        if (this.prepared && (replaceWithBinding || TranslatedCommand.isBindEligible(obj) || obj.isBindValue())) {
             buffer.append(UNDEFINED_PARAM);
             preparedValues.add(obj);
         } else {
             translateSQLType(obj.getType(), obj.getValue(), buffer);
         }
     }
+    
+    @Override
+    public void visit(IInCriteria obj) {
+        replaceWithBinding = true;
+        super.visit(obj);
+    }
 
+    @Override
+    public void visit(ILikeCriteria obj) {
+        replaceWithBinding = true;
+        super.visit(obj);
+    }
+
+    @Override
+    public void visit(ICompareCriteria obj) {
+        replaceWithBinding = true;
+        super.visit(obj);
+    }
+
+    @Override
+    public void visit(IInsertExpressionValueSource obj) {
+        replaceWithBinding = true;
+        super.visit(obj);
+    }
+    
+    @Override
+    public void visit(ISetClause obj) {
+        replaceWithBinding = true;
+        super.visit(obj);
+    }
+    
+    @Override
+    public void visit(ISelectSymbol obj) {
+    	replaceWithBinding = false;
+    	super.visit(obj);
+    }
+    
+    @Override
+    public void visit(ISearchedCaseExpression obj) {
+    	replaceWithBinding = false;
+    	super.visit(obj);
+    }
+
     /**
      * Set the per-command execution context on this visitor. 
      * @param context ExecutionContext
@@ -323,4 +358,5 @@
     protected boolean useParensForJoins() {
     	return translator.useParensForJoins();
     }
+	
 }

Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SubstringFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SubstringFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-
-/**
- * Common logic for Substring modifiers requiring 3 parameters
- */
-public class SubstringFunctionModifier extends BasicFunctionModifier {
-
-    private ILanguageFactory languageFactory;
-    private String length_function;
-    
-    public SubstringFunctionModifier(ILanguageFactory languageFactory, String length_function) {
-    	this.languageFactory = languageFactory; 
-        this.length_function = length_function;
-    }
-
-    /**
-     * @see org.teiid.connector.jdbc.translator.FunctionModifier#modify(com.metamatrix.query.sql.symbol.Function)
-     */
-    public IExpression modify(IFunction function) {
-        List<IExpression> args = function.getParameters();
-        
-        if(args.size() == 2) {
-            args.add(languageFactory.createFunction(length_function, Arrays.asList(args.get(0)), Integer.class)); 
-        } 
-                        
-        return function;
-    }
-}
\ No newline at end of file

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/TranslatedCommand.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -31,7 +31,6 @@
 import org.teiid.connector.api.TypeFacility;
 import org.teiid.connector.language.ICommand;
 import org.teiid.connector.language.ILiteral;
-import org.teiid.connector.visitor.framework.DelegatingHierarchyVisitor;
 import org.teiid.connector.visitor.util.CollectorVisitor;
 
 
@@ -47,8 +46,6 @@
     private List preparedValues;
     
     private SQLConversionVisitor sqlConversionVisitor;
-    private ReplacementVisitor functionVisitor;
-    private ExecutionContext context;
     private Translator sqlTranslator;
     
     /**
@@ -56,11 +53,9 @@
      * @param visitor a SQLConversionVisitor subclass 
      */
     public TranslatedCommand(ExecutionContext context, Translator sqlTranslator){
-    	this.context = context;
     	this.sqlTranslator = sqlTranslator;
         this.sqlConversionVisitor = sqlTranslator.getSQLConversionVisitor();
         this.sqlConversionVisitor.setExecutionContext(context);
-        this.functionVisitor = new ReplacementVisitor(context, sqlTranslator);
     }
     
     /**
@@ -76,14 +71,9 @@
         this.prepared = this.sqlConversionVisitor.isPrepared();
     }
 	
-	private String getSQL(ICommand command) throws ConnectorException {
-        command = sqlTranslator.modifyCommand(command, context);
-		command.acceptVisitor(new DelegatingHierarchyVisitor(null, this.functionVisitor));
-        
+	private String getSQL(ICommand command) {
         if (sqlTranslator.usePreparedStatements() || hasBindValue(command)) {
             this.sqlConversionVisitor.setPrepared(true);
-            
-            command.acceptVisitor(new BindValueVisitor());
         }
         
 		this.sqlConversionVisitor.append(command);

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -49,6 +49,7 @@
 import org.teiid.connector.jdbc.JDBCPlugin;
 import org.teiid.connector.jdbc.JDBCPropertyNames;
 import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 import org.teiid.connector.language.ILanguageObject;
 import org.teiid.connector.language.ILimit;
@@ -183,15 +184,30 @@
     public final ILanguageFactory getLanguageFactory() {
     	return environment.getLanguageFactory();
     }
-    
+
     /**
-     * Modify the command.
+     * Return a List of translated parts ({@link ILanguageObject}s and Objects), or null
+     * if to rely on the default translation.  Override with care.
      * @param command
      * @param context
      * @return
      */
-    public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
-    	return command;
+    public List<?> translate(ILanguageObject obj, ExecutionContext context) {
+		List<?> parts = null;
+    	if (obj instanceof IFunction) {
+    		IFunction function = (IFunction)obj;
+    		if (functionModifiers != null) {
+    			FunctionModifier modifier = functionModifiers.get(function.getName().toLowerCase());
+    			if (modifier != null) {
+    				parts = modifier.translate(function);
+    			}
+    		}
+    	} else if (obj instanceof ICommand) {
+    		parts = translateCommand((ICommand)obj, context);
+    	} else if (obj instanceof ILimit) {
+    		parts = translateLimit((ILimit)obj, context);
+    	}
+    	return parts;
     }
     
     /**
@@ -270,7 +286,7 @@
      */
     public String translateLiteralTime(Time timeValue) {
     	if (!hasTimeType()) {
-    		return "{ts'"+ getDefaultTimeYMD()+ " " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    		return "{ts'1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
     	}
         return "{t'" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -301,7 +317,7 @@
         	Timestamp ts = (Timestamp)dateObject;
         	Timestamp newTs = new Timestamp(ts.getTime());
         	if (getTimestampNanoPrecision() > 0) {
-	        	int mask = 10^(9-getTimestampNanoPrecision());
+	        	int mask = (int)Math.pow(10, 9-getTimestampNanoPrecision());
 	        	newTs.setNanos(ts.getNanos()/mask*mask);
         	} else {
         		newTs.setNanos(0);
@@ -359,10 +375,6 @@
     	return true;
     }
     
-    public String getDefaultTimeYMD() {
-    	return "1970-01-01"; //$NON-NLS-1$
-    }
-    
     /**
      * Returns the name for a given {@link ISetQuery.Operation}
      * @param operation
@@ -487,7 +499,7 @@
      * @param cal
      * @throws SQLException
      */
-    public void bindValue(PreparedStatement stmt, Object param, Class paramType, int i) throws SQLException {
+    public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
         int type = TypeFacility.getSQLTypeFromRuntimeType(paramType);
                 
         if (param == null) {

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -28,16 +28,14 @@
 import java.util.Arrays;
 import java.util.Properties;
 
+import junit.framework.TestCase;
+
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.db2.DB2ConvertModifier;
-import org.teiid.connector.jdbc.db2.DB2SQLTranslator;
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 import com.metamatrix.query.unittest.TimestampUtil;
@@ -72,20 +70,17 @@
                 LANG_FACTORY.createLiteral(tgtType, String.class)),
             TypeFacility.getDataTypeClass(tgtType));
         
-        DB2ConvertModifier mod = new DB2ConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
         assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$ 
-            expectedExpression, helpGetString(expr)); 
+            expectedExpression, helpGetString(func)); 
     }
 
     // Source = STRING
     public void testStringToChar() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "char('5', 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS char(1))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testStringToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "CASE WHEN '5' = 'true' THEN 1 ELSE 0 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "CASE WHEN '5' IN ('false', '0') THEN 0 WHEN '5' IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testStringToByte() throws Exception {
@@ -105,11 +100,11 @@
     }
 
     public void testStringToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "bigint('5')");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "cast('5' AS numeric(31,0))");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testStringToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "real('5')");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "cast(double('5') as real)");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testStringToDouble() throws Exception {
@@ -129,7 +124,7 @@
     }
 
     public void testStringToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "decimal('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "cast('5' AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = CHAR
@@ -141,7 +136,7 @@
     // Source = BOOLEAN
     
     public void testBooleanToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = 0 THEN 'false' ELSE 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = 0 THEN 'false' WHEN 1 IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToByte() throws Exception {
@@ -153,27 +148,27 @@
     }
 
     public void testBooleanToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "integer(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "bigint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "cast(1 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testBooleanToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     // Source = BYTE
@@ -183,7 +178,7 @@
     }
 
     public void testByteToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToShort() throws Exception {
@@ -191,27 +186,27 @@
     }
 
     public void testByteToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "integer(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "bigint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "cast(1 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testByteToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = SHORT
@@ -221,7 +216,7 @@
     }
 
     public void testShortToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToByte() throws Exception {
@@ -229,27 +224,27 @@
     }
 
     public void testShortToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "integer(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "bigint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "cast(1 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testShortToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = INTEGER
@@ -259,7 +254,7 @@
     }
 
     public void testIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testIntegerToByte() throws Exception {
@@ -271,23 +266,23 @@
     }
 
     public void testIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "bigint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testIntegerToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "cast(1 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = LONG
@@ -297,7 +292,7 @@
     }
 
     public void testLongToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testLongToByte() throws Exception {
@@ -313,19 +308,19 @@
     }
 
     public void testLongToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "cast(1 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testLongToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testLongToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testLongToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BIGINTEGER
@@ -335,7 +330,7 @@
     }
 
     public void testBigIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigIntegerToByte() throws Exception {
@@ -351,19 +346,19 @@
     }
 
     public void testBigIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "bigint(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "double(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "cast(1 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = FLOAT
@@ -373,7 +368,7 @@
     }
 
     public void testFloatToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "CASE WHEN 1.2 = 0 THEN 0 WHEN 1.2 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testFloatToByte() throws Exception {
@@ -393,15 +388,15 @@
     }
 
     public void testFloatToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "cast(1.2 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testFloatToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "double(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testFloatToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "cast(1.2 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = DOUBLE
@@ -411,7 +406,7 @@
     }
 
     public void testDoubleToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "CASE WHEN 1.2 = 0 THEN 0 WHEN 1.2 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testDoubleToByte() throws Exception {
@@ -431,15 +426,15 @@
     }
 
     public void testDoubleToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "cast(1.2 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testDoubleToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "real(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "cast(1.2 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testDoubleToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "cast(1.2 AS numeric(31,12))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BIGDECIMAL
@@ -449,7 +444,7 @@
     }
 
     public void testBigDecimalToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "smallint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigDecimalToByte() throws Exception {
@@ -469,15 +464,15 @@
     }
 
     public void testBigDecimalToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "bigint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "cast(1.0 AS numeric(31,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testBigDecimalToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "real(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "cast(1.0 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToDoublel() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    public void testBigDecimalToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "double(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = DATE

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -110,8 +110,8 @@
     
     @Test
     public void testSelectNullLiteral() throws Exception {
-        String input = "select null + 1 as x, null || 'a' from BQT1.Smalla"; //$NON-NLS-1$       
-        String output = "SELECT CAST(NULL AS INTEGER) AS x, CAST(NULL AS CHAR) FROM SmallA";  //$NON-NLS-1$
+        String input = "select null + 1 as x, null || 'a', char(null) from BQT1.Smalla"; //$NON-NLS-1$       
+        String output = "SELECT cast(NULL AS integer) AS x, cast(NULL AS char), cast(NULL AS char(1)) FROM SmallA";  //$NON-NLS-1$
         
         helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
                 input, 

Deleted: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbyConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,523 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.derby;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.Properties;
-
-import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.derby.DerbyConvertModifier;
-import org.teiid.connector.jdbc.derby.DerbySQLTranslator;
-import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.query.unittest.TimestampUtil;
-
-/**
- */
-public class TestDerbyConvertModifier extends TestCase {
-
-    private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
-    /**
-     * Constructor for TestSybaseConvertModifier.
-     * @param name
-     */
-    public TestDerbyConvertModifier(String name) {
-        super(name);
-    }
-
-    public String helpGetString(IExpression expr) throws Exception {
-        DerbySQLTranslator trans = new DerbySQLTranslator();
-        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
-        
-        SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
-        
-        return sqlVisitor.toString();        
-    }
-
-    public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
-            Arrays.asList( 
-                srcExpression,
-                LANG_FACTORY.createLiteral(tgtType, String.class)),
-            TypeFacility.getDataTypeClass(tgtType));
-        
-        DerbyConvertModifier mod = new DerbyConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
-        assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$ 
-            expectedExpression, helpGetString(expr)); 
-    }
-
-    // Source = STRING
-
-    public void testStringToChar() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "char('5', 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "CASE WHEN '5' = 'true' THEN 1 ELSE 0 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "byte", "smallint('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "short", "smallint('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "integer", "integer('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "long", "bigint('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "bigint('5')");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "cast(cast('5' AS decimal) AS float)");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "double", "cast(cast('5' AS decimal) AS double)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToDate() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("2004-06-29", String.class), "date", "date('2004-06-29')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToTime() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("23:59:59", String.class), "time", "time('23:59:59')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToTimestamp() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("2004-06-29 23:59:59.987", String.class), "timestamp", "timestamp('2004-06-29 23:59:59.987')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testStringToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "cast('5' AS decimal)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    // Source = CHAR
-    
-    public void testCharToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "'5'"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = BOOLEAN
-    
-    public void testBooleanToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = 0 THEN 'false' ELSE 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testBooleanToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    // Source = BYTE
-    
-    public void testByteToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testByteToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = SHORT
-    
-    public void testShortToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testShortToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = INTEGER
-    
-    public void testIntegerToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "byte", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "short", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = LONG
-    
-    public void testLongToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "byte", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "short", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "integer", "integer(1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testLongToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = BIGINTEGER
-    
-    public void testBigIntegerToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "char(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "byte", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "short", "smallint(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "integer", "integer(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    // Source = FLOAT
-    
-    public void testFloatToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "char(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "byte", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "short", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "integer", "integer(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testFloatToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = DOUBLE
-    
-    public void testDoubleToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "char(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "byte", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "smallint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "integer", "integer(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "bigint(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "cast(1.2 AS float)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDoubleToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = BIGDECIMAL
-    
-    public void testBigDecimalToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "string", "char(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "smallint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "smallint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "short", "smallint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "integer", "integer(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "bigint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "bigint(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "cast(1.0 AS float)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    public void testBigDecimalToDoublel() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-    // Source = DATE
-
-    public void testDateToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d'2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testDateToTimestamp() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d'2003-11-01'}, '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = TIME
-
-    public void testTimeToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testTimeToTimestamp() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    // Source = TIMESTAMP
-    
-    public void testTimestampToString() throws Exception {
-        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
-        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testTimestampToDate() throws Exception {
-        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
-        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testTimestampToTime() throws Exception {
-    	Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
-        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    
-}

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -66,28 +66,8 @@
         
         assertEquals("Did not get correct sql", expectedOutput, tc.getSql());             //$NON-NLS-1$
     }
-
-    @Test
-    public void testRowLimit() throws Exception {
-        String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
-        String output = "SELECT SmallA.IntKey FROM SmallA FETCH FIRST 100 ROWS ONLY";  //$NON-NLS-1$
-
-        helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
-            input, 
-            output);
-    }
     
     @Test
-    public void testCrossJoin() throws Exception{
-        String input = "SELECT bqt1.smalla.stringkey FROM bqt1.smalla cross join bqt1.smallb"; //$NON-NLS-1$
-        String output = "SELECT SmallA.StringKey FROM SmallA INNER JOIN SmallB ON 1 = 1";  //$NON-NLS-1$
-
-        helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
-            input, 
-            output);
-    }
-    
-    @Test
     public void testConcat_useLiteral() throws Exception {
         String input = "select concat(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$
         String output = "SELECT {fn concat(SmallA.StringNum, '_xx')} FROM SmallA";  //$NON-NLS-1$
@@ -129,133 +109,4 @@
                 output);
     }    
     
-    @Test
-    public void testSelectNullLiteral() throws Exception {
-        String input = "select null + 1 as x, null || 'a' from BQT1.Smalla"; //$NON-NLS-1$       
-        String output = "SELECT CAST(NULL AS INTEGER) AS x, CAST(NULL AS CHAR) FROM SmallA";  //$NON-NLS-1$
-        
-        helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
-                input, 
-                output);
-    }    
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate() throws Exception {
-        String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(char(SmallA.IntNum), 'chimp', 1) FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate2() throws Exception {
-        String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(SmallA.StringNum, 'chimp') FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate3() throws Exception {
-        String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(char(SmallA.IntNum), '234567890', 1) FROM SmallA WHERE SmallA.IntKey = 26";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate4() throws Exception {
-        String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT 1 FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate5() throws Exception {
-        String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', 1) FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate6() throws Exception {
-        String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END) FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
-    /**
-     * Test the translator's ability to rewrite the LOCATE() function in a form 
-     * suitable for the data source.
-     * <p>
-     * <code>SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA</code>
-     *  
-     * @throws Exception
-     */
-    @Test public void testLocate7() throws Exception {
-        String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN (LOCATE(SmallA.StringNum, 'chimp') + 1) < 1 THEN 1 ELSE (LOCATE(SmallA.StringNum, 'chimp') + 1) END) FROM SmallA";  //$NON-NLS-1$
-
-        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
-                input, output, 
-                TRANSLATOR);
-    }
-
 }

Deleted: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestDropFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestDropFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestDropFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.extension.impl;
-
-import java.util.Arrays;
-
-import org.teiid.connector.jdbc.translator.DropFunctionModifier;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILiteral;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-
-/**
- */
-public class TestDropFunctionModifier extends TestCase {
-
-    /**
-     * Constructor for TestDropFunctionModifier.
-     * @param name
-     */
-    public TestDropFunctionModifier(String name) {
-        super(name);
-    }
-
-    public void testDrop() {
-        DropFunctionModifier mod = new DropFunctionModifier();
-    
-        ILiteral arg1 = CommandBuilder.getLanuageFactory().createLiteral(new Integer(5), Integer.class);
-        ILiteral arg2 = CommandBuilder.getLanuageFactory().createLiteral("string", String.class);//$NON-NLS-1$
-        IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", Arrays.asList(arg1, arg2), Integer.class); //$NON-NLS-1$
-                
-        IExpression output = mod.modify(func);
-        assertEquals("Did not get expected function after using drop modifier", arg1, output); //$NON-NLS-1$
-    }
-    
-    /**
-     * In SQL Server convert(), the type arg is the first arg, and the column name
-     * is the second arg.  DropFunctionModifier needs to be able to handle the column name
-     * arg being in different indices.
-     */
-    public void testDrop2() {
-        DropFunctionModifier mod = new DropFunctionModifier();
-        mod.setReplaceIndex(1);
-    
-        ILiteral arg1 = CommandBuilder.getLanuageFactory().createLiteral("string", String.class);//$NON-NLS-1$
-        ILiteral arg2 = CommandBuilder.getLanuageFactory().createLiteral(new Integer(5), Integer.class);
-        IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", Arrays.asList(arg1, arg2), Integer.class); //$NON-NLS-1$
-                
-        IExpression output = mod.modify(func);
-        assertEquals("Did not get expected function after using drop modifier", arg2, output); //$NON-NLS-1$
-    }
-    
-}

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -68,7 +68,6 @@
 	private void helpTest(IFunction func, String expected) {
         EscapeSyntaxModifier mod = new EscapeSyntaxModifier();
 
-		func = (IFunction) mod.modify(func);
         List parts = mod.translate(func);
         StringBuffer sb = new StringBuffer();
         for (Object object : parts) {

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -52,7 +52,7 @@
     
     @Test public void testConversion1() throws Exception {
         String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT char((convert(PARTS.PART_WEIGHT, SIGNED INTEGER) + 100)) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT char((cast(PARTS.PART_WEIGHT AS signed) + 100)) FROM PARTS";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(getTestVDB(),
             input, 
@@ -61,7 +61,7 @@
           
     @Test public void testConversion2() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(PARTS.PART_WEIGHT, SIGNED) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS signed) FROM PARTS";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(getTestVDB(),
             input, 
@@ -70,7 +70,7 @@
           
     @Test public void testConversion3() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, long), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(convert(PARTS.PART_WEIGHT, SIGNED), CHAR) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(getTestVDB(),
             input, 
@@ -111,7 +111,7 @@
     }
     @Test public void testConversion7() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, integer), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(convert(PARTS.PART_WEIGHT, SIGNED INTEGER), CHAR) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(getTestVDB(),
             input, 
@@ -136,7 +136,7 @@
      */
     @Test public void testLocate() throws Exception {
         String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(convert(SmallA.IntNum, CHAR), 'chimp', 1) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT LOCATE(cast(SmallA.IntNum AS char), 'chimp', 1) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -170,7 +170,7 @@
      */
     @Test public void testLocate3() throws Exception {
         String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
-        String output = "SELECT LOCATE(convert(SmallA.IntNum, CHAR), '234567890', 1) FROM SmallA WHERE SmallA.IntKey = 26";  //$NON-NLS-1$
+        String output = "SELECT LOCATE(cast(SmallA.IntNum AS char), '234567890', 1) FROM SmallA WHERE SmallA.IntKey = 26";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -290,7 +290,7 @@
     
     @Test public void testBitAnd() throws Exception {
         String input = "select bitand(intkey, intnum) from bqt1.smalla"; //$NON-NLS-1$
-        String output = "SELECT convert((SmallA.IntKey & SmallA.IntNum), SIGNED INTEGER) FROM SmallA"; //$NON-NLS-1$
+        String output = "SELECT cast((SmallA.IntKey & SmallA.IntNum) AS signed) FROM SmallA"; //$NON-NLS-1$
                
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
             input, 

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -26,16 +26,14 @@
 import java.util.Arrays;
 import java.util.Properties;
 
-import org.teiid.connector.jdbc.oracle.DayWeekQuarterFunctionModifier;
-import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
+import junit.framework.TestCase;
+
+import org.teiid.connector.api.SourceSystemFunctions;
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
-import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 import org.teiid.connector.language.ILiteral;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 import com.metamatrix.query.unittest.TimestampUtil;
@@ -54,81 +52,40 @@
         super(name);
     }
 
-    public IExpression helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("dayweekquarter",  //$NON-NLS-1$ 
+    public void helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
+        IFunction func = LANG_FACTORY.createFunction(format,  
             Arrays.asList(c),
             String.class);
         
-        DayWeekQuarterFunctionModifier mod = new DayWeekQuarterFunctionModifier (LANG_FACTORY, format);
-        IExpression expr = mod.modify(func);
-        
         OracleSQLTranslator trans = new OracleSQLTranslator();
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
         
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
+        sqlVisitor.append(func);  
         assertEquals(expectedStr, sqlVisitor.toString());
-        
-        return expr;
     }
 
     public void test1() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
-        helpTestMod(arg1, "DDD", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
+        helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR, 
+            "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
     }
 
     public void test2() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
-        helpTestMod(arg1, "DDD", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({d'2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
+        helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR, 
+            "to_number(TO_CHAR({d'2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
     }
     
-    public void test3() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
-        helpTestMod(arg1, "D",  //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'D'))"); //$NON-NLS-1$
-    }
-
-    public void test4() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
-        helpTestMod(arg1, "D", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({d'2004-01-21'}, 'D'))"); //$NON-NLS-1$
-    }
-    
-    public void test5() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
-        helpTestMod(arg1, "DD",  //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'DD'))"); //$NON-NLS-1$
-    }
-
-    public void test6() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
-        helpTestMod(arg1, "DD", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({d'2004-01-21'}, 'DD'))"); //$NON-NLS-1$
-    }
-    
-    public void test7() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
-        helpTestMod(arg1, "WW",  //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'WW'))"); //$NON-NLS-1$
-    }
-
-    public void test8() throws Exception {
-        ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
-        helpTestMod(arg1, "WW", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({d'2004-01-21'}, 'WW'))"); //$NON-NLS-1$
-    }
-    
     public void test9() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
-        helpTestMod(arg1, "Q",  //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
+        helpTestMod(arg1, SourceSystemFunctions.QUARTER,
+            "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
     }
 
     public void test10() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
-        helpTestMod(arg1, "Q", //$NON-NLS-1$
-            "TO_NUMBER(TO_CHAR({d'2004-01-21'}, 'Q'))"); //$NON-NLS-1$
+        helpTestMod(arg1, SourceSystemFunctions.QUARTER, 
+            "to_number(TO_CHAR({d'2004-01-21'}, 'Q'))"); //$NON-NLS-1$
     }
 }
\ No newline at end of file

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -28,7 +28,6 @@
 import junit.framework.TestCase;
 
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
-import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 import org.teiid.connector.language.ILiteral;
@@ -50,23 +49,17 @@
         super(name);
     }
 
-    public IExpression helpTestMod(ILiteral c, ILiteral d, String target, String expectedStr) throws Exception {
+    public void helpTestMod(ILiteral c, ILiteral d, String target, String expectedStr) throws Exception {
         IFunction func = LANG_FACTORY.createFunction(target,
             Arrays.asList( c, d ),
             String.class);
         
-        LeftOrRightFunctionModifier mod = new LeftOrRightFunctionModifier (LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
         OracleSQLTranslator trans = new OracleSQLTranslator();
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
         
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
-        //System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
+        sqlVisitor.append(func);  
         assertEquals(expectedStr, sqlVisitor.toString());
-        
-        return expr;
     }
 
     public void test1() throws Exception {

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLog10FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLog10FunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestLog10FunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -52,14 +52,11 @@
         IFunction func = CommandBuilder.getLanuageFactory().createFunction("log10", Arrays.asList(arg), Double.class); //$NON-NLS-1$
         
         Log10FunctionModifier modifier = new Log10FunctionModifier(CommandBuilder.getLanuageFactory());
-        IExpression outExpr = modifier.modify(func);
+        modifier.translate(func);
         
-        assertTrue(outExpr instanceof IFunction);
-        IFunction outFunc = (IFunction) outExpr;
+        assertEquals("log", func.getName()); //$NON-NLS-1$
+        assertEquals(Double.class, func.getType());
         
-        assertEquals("log", outFunc.getName()); //$NON-NLS-1$
-        assertEquals(func.getType(), outFunc.getType());
-        
         List<IExpression> outArgs = func.getParameters();
         assertEquals(2, outArgs.size());
         assertEquals(arg, outArgs.get(1));
@@ -69,6 +66,6 @@
         assertEquals(Integer.class, newArg.getType());
         assertEquals(new Integer(10), newArg.getValue());
         
-        assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(outFunc));              //$NON-NLS-1$
+        assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(func));              //$NON-NLS-1$
     }
 }

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -26,16 +26,13 @@
 import java.util.Arrays;
 import java.util.Properties;
 
-import org.teiid.connector.jdbc.oracle.MonthOrDayNameFunctionModifier;
-import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
+import junit.framework.TestCase;
+
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
-import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 import org.teiid.connector.language.ILiteral;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 import com.metamatrix.query.unittest.TimestampUtil;
@@ -54,44 +51,40 @@
         super(name);
     }
 
-    public IExpression helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
+    public void helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
         IFunction func = LANG_FACTORY.createFunction(format.toLowerCase()+"name",  // "monthname" //$NON-NLS-1$ 
             Arrays.asList( c ),
             String.class);
         
-        MonthOrDayNameFunctionModifier mod = new MonthOrDayNameFunctionModifier (LANG_FACTORY, format);
-        IExpression expr = mod.modify(func);
-        
         OracleSQLTranslator trans = new OracleSQLTranslator();
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
         
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
+        sqlVisitor.append(func);  
         assertEquals(expectedStr, sqlVisitor.toString());
-        return expr;
     }
 
     public void test1() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
         helpTestMod(arg1, "Month", //$NON-NLS-1$
-            "RTRIM(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
+            "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
     }
 
     public void test2() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
         helpTestMod(arg1, "Month", //$NON-NLS-1$
-            "RTRIM(TO_CHAR({d'2004-01-21'}, 'Month'))"); //$NON-NLS-1$
+            "rtrim(TO_CHAR({d'2004-01-21'}, 'Month'))"); //$NON-NLS-1$
     }
     
     public void test3() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
         helpTestMod(arg1, "Day",  //$NON-NLS-1$
-            "RTRIM(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
+            "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
     }
 
     public void test4() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
         helpTestMod(arg1, "Day", //$NON-NLS-1$
-            "RTRIM(TO_CHAR({d'2004-01-21'}, 'Day'))"); //$NON-NLS-1$
+            "rtrim(TO_CHAR({d'2004-01-21'}, 'Day'))"); //$NON-NLS-1$
     }
 }
\ No newline at end of file

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -28,39 +28,37 @@
 import java.util.Arrays;
 import java.util.Properties;
 
+import static org.junit.Assert.*;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.oracle.OracleConvertModifier;
-import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
+import org.teiid.connector.jdbc.translator.Translator;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 import com.metamatrix.query.unittest.TimestampUtil;
 
 /**
  */
-public class TestOracleConvertModifier extends TestCase {
+public class TestOracleConvertModifier {
 
     private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
-    /**
-     * Constructor for TestSybaseConvertModifier.
-     * @param name
-     */
-    public TestOracleConvertModifier(String name) {
-        super(name);
+    private static Translator TRANSLATOR = new OracleSQLTranslator(); 
+    
+    @BeforeClass public static void oneTimeSetup() throws Exception {
+        TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
     }
-
+    
     public String helpGetString(IExpression expr) throws Exception {
         OracleSQLTranslator trans = new OracleSQLTranslator();
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
         
-        SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
+        SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor(); 
         sqlVisitor.append(expr);  
         
         return sqlVisitor.toString();        
@@ -73,450 +71,447 @@
                 LANG_FACTORY.createLiteral(tgtType, String.class)),
             TypeFacility.getDataTypeClass(tgtType));
         
-        OracleConvertModifier mod = new OracleConvertModifier(LANG_FACTORY, null);
-        IExpression expr = mod.modify(func);
-        
         assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$ 
-            expectedExpression, helpGetString(expr)); 
+            expectedExpression, helpGetString(func)); 
     }
 
     // Source = STRING
 
-    public void testStringToChar() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "'5'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToChar() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS char(1))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "decode('5', 'true', 1, 'false', 0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "CASE WHEN '5' IN ('false', '0') THEN 0 WHEN '5' IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "byte", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToByte() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "byte", "trunc(to_number('5'))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "short", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToShort() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "short", "trunc(to_number('5'))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "integer", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "integer", "trunc(to_number('5'))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "long", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "long", "trunc(to_number('5'))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "to_number('5')");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "trunc(to_number('5'))");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToFloat() throws Exception {
+    @Test public void testStringToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "to_number('5')");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToDouble() throws Exception {
+    @Test public void testStringToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral("5", String.class), "double", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToDate() throws Exception {
+    @Test public void testStringToDate() throws Exception {
         helpTest(LANG_FACTORY.createLiteral("2004-06-29", String.class), "date", "to_date('2004-06-29', 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToTime() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral("23:59:59", String.class), "time", "to_date(('1970-01-01 ' || to_char('23:59:59', 'HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testStringToTime() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral("23:59:59", String.class), "time", "to_date('23:59:59', 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToTimestamp() throws Exception {
+    @Test public void testStringToTimestamp() throws Exception {
         helpTest(LANG_FACTORY.createLiteral("2004-06-29 23:59:59.987", String.class), "timestamp", "to_timestamp('2004-06-29 23:59:59.987', 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testStringToBigDecimal() throws Exception {
+    @Test public void testStringToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "to_number('5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = CHAR
     
-    public void testCharToString() throws Exception {
+    @Test public void testCharToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "'5'"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BOOLEAN
     
-    public void testBooleanToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "decode(1, 0, 'false', 1, 'true')"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = 0 THEN 'false' WHEN 1 IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToByte() throws Exception {
+    @Test public void testBooleanToByte() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToShort() throws Exception {
+    @Test public void testBooleanToShort() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToInteger() throws Exception {
+    @Test public void testBooleanToInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToLong() throws Exception {
+    @Test public void testBooleanToLong() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToBigInteger() throws Exception {
+    @Test public void testBooleanToBigInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToFloat() throws Exception {
+    @Test public void testBooleanToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToDouble() throws Exception {
+    @Test public void testBooleanToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToBigDecimal() throws Exception {
+    @Test public void testBooleanToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     // Source = BYTE
     
-    public void testByteToString() throws Exception {
+    @Test public void testByteToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "to_char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToShort() throws Exception {
+    @Test public void testByteToShort() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToInteger() throws Exception {
+    @Test public void testByteToInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToLong() throws Exception {
+    @Test public void testByteToLong() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToBigInteger() throws Exception {
+    @Test public void testByteToBigInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToFloat() throws Exception {
+    @Test public void testByteToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToDouble() throws Exception {
+    @Test public void testByteToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToBigDecimal() throws Exception {
+    @Test public void testByteToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = SHORT
     
-    public void testShortToString() throws Exception {
+    @Test public void testShortToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "to_char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToByte() throws Exception {
+    @Test public void testShortToByte() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToInteger() throws Exception {
+    @Test public void testShortToInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToLong() throws Exception {
+    @Test public void testShortToLong() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToBigInteger() throws Exception {
+    @Test public void testShortToBigInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToFloat() throws Exception {
+    @Test public void testShortToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToDouble() throws Exception {
+    @Test public void testShortToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToBigDecimal() throws Exception {
+    @Test public void testShortToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = INTEGER
     
-    public void testIntegerToString() throws Exception {
+    @Test public void testIntegerToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "to_char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToByte() throws Exception {
+    @Test public void testIntegerToByte() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToShort() throws Exception {
+    @Test public void testIntegerToShort() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToLong() throws Exception {
+    @Test public void testIntegerToLong() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToBigInteger() throws Exception {
+    @Test public void testIntegerToBigInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToFloat() throws Exception {
+    @Test public void testIntegerToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToDouble() throws Exception {
+    @Test public void testIntegerToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToBigDecimal() throws Exception {
+    @Test public void testIntegerToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = LONG
     
-    public void testLongToString() throws Exception {
+    @Test public void testLongToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "to_char(1)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToByte() throws Exception {
+    @Test public void testLongToByte() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToShort() throws Exception {
+    @Test public void testLongToShort() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToInteger() throws Exception {
+    @Test public void testLongToInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToBigInteger() throws Exception {
+    @Test public void testLongToBigInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToFloat() throws Exception {
+    @Test public void testLongToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToDouble() throws Exception {
+    @Test public void testLongToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToBigDecimal() throws Exception {
+    @Test public void testLongToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BIGINTEGER
     
-    public void testBigIntegerToString() throws Exception {
+    @Test public void testBigIntegerToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "to_char(1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToByte() throws Exception {
+    @Test public void testBigIntegerToByte() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToShort() throws Exception {
+    @Test public void testBigIntegerToShort() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToInteger() throws Exception {
+    @Test public void testBigIntegerToInteger() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "integer", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToLong() throws Exception {
+    @Test public void testBigIntegerToLong() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToFloat() throws Exception {
+    @Test public void testBigIntegerToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToDouble() throws Exception {
+    @Test public void testBigIntegerToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToBigDecimal() throws Exception {
+    @Test public void testBigIntegerToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = FLOAT
     
-    public void testFloatToString() throws Exception {
+    @Test public void testFloatToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "to_char(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "CASE WHEN 1.2 = 0 THEN 0 WHEN 1.2 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "byte", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToByte() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "byte", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "short", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToShort() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "short", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "integer", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "integer", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToDouble() throws Exception {
+    @Test public void testFloatToDouble() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToBigDecimal() throws Exception {
+    @Test public void testFloatToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = DOUBLE
     
-    public void testDoubleToString() throws Exception {
+    @Test public void testDoubleToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "to_char(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "CASE WHEN 1.2 = 0 THEN 0 WHEN 1.2 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "byte", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToByte() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "byte", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToShort() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "integer", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "integer", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "trunc(1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToFloat() throws Exception {
+    @Test public void testDoubleToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToBigDecimal() throws Exception {
+    @Test public void testDoubleToBigDecimal() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "1.2"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BIGDECIMAL
     
-    public void testBigDecimalToString() throws Exception {
+    @Test public void testBigDecimalToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "string", "to_char(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToBoolean() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToBoolean() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToByte() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "trunc(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "short", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToShort() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "short", "trunc(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "integer", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "integer", "trunc(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "trunc(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "trunc(1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToFloat() throws Exception {
+    @Test public void testBigDecimalToFloat() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToDoublel() throws Exception {
+    @Test public void testBigDecimalToDoublel() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = DATE
 
-    public void testDateToString() throws Exception {
+    @Test public void testDateToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "to_char({d'2003-11-01'}, 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDateToTimestamp() throws Exception {
+    @Test public void testDateToTimestamp() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d'2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = TIME
 
-    public void testTimeToString() throws Exception {
+    @Test public void testTimeToString() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts'1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testTimeToTimestamp() throws Exception {
+    @Test public void testTimeToTimestamp() throws Exception {
         helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts'1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = TIMESTAMP
     
-    public void testTimestampToString() throws Exception {
+    @Test public void testTimestampToString() throws Exception {
         Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
         helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts'2003-11-01 12:05:02.0'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testTimestampToDate() throws Exception {
+    @Test public void testTimestampToDate() throws Exception {
         Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
-        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc(cast({ts'2003-11-01 12:05:02.0'} AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testTimestampToTime() throws Exception {
+    @Test public void testTimestampToTime() throws Exception {
         Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);        
-        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "to_date(('1970-01-01 ' || to_char({ts'2003-11-01 12:05:02.0'}, 'HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "to_date('1970-01-01 ' || to_char({ts'2003-11-01 12:05:02.0'}, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
 }

Copied: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java (from rev 1286, trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -0,0 +1,348 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.oracle;
+
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
+import org.teiid.connector.jdbc.translator.TranslatedCommand;
+import org.teiid.connector.language.ICommand;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
+import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
+
+import com.metamatrix.cdk.CommandBuilder;
+import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+import com.metamatrix.query.unittest.FakeMetadataStore;
+
+public class TestOracleSQLConversionVisitor {
+    private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
+    
+    private String getTestVDB() {
+        return UnitTestUtil.getTestDataPath() + "/PartsSupplierOracle.vdb"; //$NON-NLS-1$
+    }
+    
+    private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+        helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, false);
+    }
+
+    private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
+        helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
+    }
+
+    private void helpTestVisitor(String vdb, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
+        // Convert from sql to objects
+        TranslationUtility util = new TranslationUtility(vdb);
+        ICommand obj =  util.parseCommand(input, correctNaming, true);        
+		this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
+    }
+
+    /** Helper method takes a QueryMetadataInterface impl instead of a VDB filename 
+     * @throws ConnectorException 
+     */
+    private void helpTestVisitor(QueryMetadataInterface metadata, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+        // Convert from sql to objects
+        CommandBuilder commandBuilder = new CommandBuilder(metadata);
+        ICommand obj = commandBuilder.getCommand(input);
+		this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
+    }
+    
+    private void helpTestVisitor(ICommand obj, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+
+        
+        // Apply function replacement
+        OracleSQLTranslator translator = new OracleSQLTranslator();
+        Properties p = new Properties();
+        if (dbmsTimeZone != null) {
+        	p.setProperty(JDBCPropertyNames.DATABASE_TIME_ZONE, dbmsTimeZone);
+        }
+        translator.initialize(EnvironmentUtility.createEnvironment(p, false));
+        // Convert back to SQL
+        TranslatedCommand tc = new TranslatedCommand(context, translator);
+        tc.translateCommand(obj);
+        
+        // Check stuff
+        assertEquals("Did not get correct sql", expectedOutput, tc.getSql());             //$NON-NLS-1$
+    }
+    
+    /** defect 21775 */
+    @Test public void testDateStuff() throws Exception {
+        String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY datevalue"; //$NON-NLS-1$
+        String output = "SELECT CASE WHEN (CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE con!
 cat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END IS NULL) OR (to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL) THEN NULL ELSE concat(CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FR!
 OM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.D!
 ateValue
) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END, to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
+        
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                        input, 
+                        EMPTY_CONTEXT, null, output);
+    }
+    
+    @Test public void testAliasedGroup() throws Exception {
+        helpTestVisitor(getTestVDB(),
+            "select y.part_name from parts as y", //$NON-NLS-1$
+            null,
+            "SELECT y.PART_NAME FROM PARTS y"); //$NON-NLS-1$
+    }
+    
+    @Test public void testDateLiteral() throws Exception {
+        helpTestVisitor(getTestVDB(),
+            "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
+            null,
+            "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+    }
+
+    @Test public void testTimeLiteral() throws Exception {
+        helpTestVisitor(getTestVDB(),
+            "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
+            null,
+            "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+    }
+
+    @Test public void testTimestampLiteral() throws Exception {
+        helpTestVisitor(getTestVDB(),
+            "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+            null,
+            "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+    }
+
+    @Test public void testUnionOrderByWithThreeBranches() throws Exception {
+        helpTestVisitor(getTestVDB(),
+                        "select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
+                        null,
+                        "(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+                        true); 
+    }
+    
+    @Test public void testUnionOrderBy() throws Exception {
+        helpTestVisitor(getTestVDB(),
+                        "select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
+                        null,
+                        "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+                        true); 
+    }
+
+    @Test public void testUnionOrderBy2() throws Exception {
+        helpTestVisitor(getTestVDB(),
+                        "select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
+                        null,
+                        "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p NULLS FIRST"); //$NON-NLS-1$
+    }
+
+    @Test public void testUpdateWithFunction() throws Exception {
+        String input = "UPDATE bqt1.smalla SET intkey = intkey + 1"; //$NON-NLS-1$
+        String output = "UPDATE SmallA SET IntKey = (SmallA.IntKey + 1)"; //$NON-NLS-1$
+        
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                input, 
+                EMPTY_CONTEXT, null, output);
+    }
+    
+
+    /**
+     * Oracle's DUAL table is a pseudo-table; element names cannot be 
+     * fully qualified since the table doesn't really exist nor contain
+     * any columns.  But this requires modeling the DUAL table in 
+     * MM as if it were a real physical table, and also modeling any
+     * columns in the table.  Case 3742
+     * 
+     * @since 4.3
+     */
+    @Test public void testDUAL() throws Exception {
+        String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
+        String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
+               
+        helpTestVisitor(getTestVDB(),
+            input, 
+            null,
+            output);
+    }
+
+    /**
+     * Test Oracle's rownum pseudo-column.  Not a real column, so it can't
+     * be fully-qualified with a table name.  MM requires this column to be
+     * modeled in any table which the user wants to use rownum with.
+     * Case 3739
+     * 
+     * @since 4.3
+     */
+    @Test public void testROWNUM() throws Exception {
+        String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
+        String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
+               
+        helpTestVisitor(getTestVDB(),
+            input, 
+            null,
+            output);        
+    }
+    
+    /**
+     * Test Oracle's rownum pseudo-column.  Not a real column, so it can't
+     * be fully-qualified with a table name.  MM requires this column to be
+     * modeled in any table which the user wants to use rownum with.  Case 3739
+     * 
+     * @since 4.3
+     */
+    @Test public void testROWNUM2() throws Exception {
+        String input = "SELECT part_name FROM parts where rownum < 100"; //$NON-NLS-1$
+        String output = "SELECT PARTS.PART_NAME FROM PARTS WHERE ROWNUM < 100"; //$NON-NLS-1$
+               
+        helpTestVisitor(getTestVDB(),
+            input, 
+            null,
+            output);        
+    }    
+    
+    /**
+     * Case 3744.  Test that an Oracle-specific db hint, delivered as a String via command
+     * payload, is added to the translated SQL.
+     * 
+     * @since 4.3
+     */
+    @Test public void testOracleCommentPayload() throws Exception {
+        String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
+        String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
+               
+        String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
+        ExecutionContext context = new ExecutionContextImpl(null, null, null, null, hint, null, "", null, null, null); //$NON-NLS-1$
+        
+        helpTestVisitor(getTestVDB(),
+            input, 
+            context,
+            null,
+            output,
+            false);        
+    }
+    
+    /**
+     * reproducing this case relies on the name in source for the table being different from
+     * the name
+     */
+    @Test public void testCase3845() throws Exception {
+        
+        String input = "SELECT (DoubleNum * 1.0) FROM BQT1.Smalla"; //$NON-NLS-1$
+        String output = "SELECT (SmallishA.DoubleNum * 1.0) FROM SmallishA"; //$NON-NLS-1$
+
+        FakeMetadataFacade metadata = exampleCase3845();
+
+        helpTestVisitor(metadata, input, EMPTY_CONTEXT, null, output);
+    }
+    
+    /** create fake BQT metadata to test this case, name in source is important */
+    private FakeMetadataFacade exampleCase3845() { 
+        // Create models
+        FakeMetadataObject bqt1 = FakeMetadataFactory.createPhysicalModel("BQT1"); //$NON-NLS-1$
+        FakeMetadataObject bqt1SmallA = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
+        bqt1SmallA.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "SmallishA");//$NON-NLS-1$
+        FakeMetadataObject doubleNum = FakeMetadataFactory.createElement("BQT1.SmallA.DoubleNum", bqt1SmallA, DataTypeManager.DefaultDataTypes.DOUBLE, 0); //$NON-NLS-1$
+
+        FakeMetadataStore store = new FakeMetadataStore();
+        store.addObject(bqt1);
+        store.addObject(bqt1SmallA);
+        store.addObject(doubleNum);
+        return new FakeMetadataFacade(store);
+    }
+
+	public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
+		helpTestVisitor(vdb, input, null, expectedOutput);
+	}
+
+    @Test public void testRowLimit2() throws Exception {
+        String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
+        String output = "SELECT * FROM (SELECT SmallA.IntKey FROM SmallA) WHERE ROWNUM <= 100"; //$NON-NLS-1$
+               
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                input, 
+                EMPTY_CONTEXT, null, output);        
+    }
+    
+    @Test public void testRowLimit3() throws Exception {
+        String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
+        String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50"; //$NON-NLS-1$
+               
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                input, 
+                EMPTY_CONTEXT, null, output);        
+    }
+            
+    @Test public void testLimitWithNestedInlineView() throws Exception {
+        String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
+        String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey NULLS FIRST) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
+               
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                input, 
+                EMPTY_CONTEXT, null, output);        
+    }
+    
+    @Test public void testExceptAsMinus() throws Exception {
+        String input = "select intkey, intnum from bqt1.smalla except select intnum, intkey from bqt1.smallb"; //$NON-NLS-1$
+        String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA MINUS SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB"; //$NON-NLS-1$
+               
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+                input, 
+                EMPTY_CONTEXT, null, output);        
+    }
+    
+    @Test public void testConcat2_useLiteral() throws Exception {
+        String sql = "select concat2(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$       
+        String expected = "SELECT concat(nvl(SmallA.StringNum, ''), '_xx') FROM SmallA"; //$NON-NLS-1$
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+    }
+
+    @Test public void testConcat2() throws Exception {
+        String sql = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$       
+        String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(nvl(SmallA.StringNum, ''), nvl(SmallA.StringNum, '')) END FROM SmallA"; //$NON-NLS-1$
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+    }
+    
+    @Test public void testConcat() throws Exception {
+        String sql = "select concat(stringnum, stringkey) from BQT1.Smalla"; //$NON-NLS-1$       
+        String expected = "SELECT CASE WHEN (SmallA.StringNum IS NULL) OR (SmallA.StringKey IS NULL) THEN NULL ELSE concat(SmallA.StringNum, SmallA.StringKey) END FROM SmallA"; //$NON-NLS-1$
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+    }
+    
+    @Test public void testConcat_withLiteral() throws Exception {
+        String sql = "select stringnum || '1' from BQT1.Smalla"; //$NON-NLS-1$       
+        String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(SmallA.StringNum, '1') END FROM SmallA"; //$NON-NLS-1$
+        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+    }
+    
+    @Test public void testRowLimitWithUnionOrderBy() throws Exception {
+        String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
+        String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0 NULLS FIRST"; //$NON-NLS-1$
+               
+        CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
+        ICommand obj = commandBuilder.getCommand(input, true, true);
+		this.helpTestVisitor(obj, EMPTY_CONTEXT, null, output);
+    }
+
+}

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -117,7 +117,7 @@
     
 	@Test public void testConversion1() throws Exception {
         String input = "SELECT char(convert(STRINGNUM, integer) + 100) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT chr((to_number(SmallA.StringNum) + 100)) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT chr((trunc(to_number(SmallA.StringNum)) + 100)) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
             input, output, 
@@ -126,7 +126,7 @@
           
     @Test public void testConversion2() throws Exception {
         String input = "SELECT convert(STRINGNUM, long) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT to_number(SmallA.StringNum) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT trunc(to_number(SmallA.StringNum)) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -135,7 +135,7 @@
           
     @Test public void testConversion3() throws Exception {
         String input = "SELECT convert(convert(STRINGNUM, long), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_number(SmallA.StringNum)) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT to_char(trunc(to_number(SmallA.StringNum))) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -144,7 +144,7 @@
           
     @Test public void testConversion4() throws Exception {
         String input = "SELECT convert(convert(TIMESTAMPVALUE, date), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT to_char(trunc(SmallA.TimestampValue), 'YYYY-MM-DD') FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT to_char(trunc(cast(SmallA.TimestampValue AS date)), 'YYYY-MM-DD') FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -152,7 +152,7 @@
     }
     @Test public void testConversion5() throws Exception {
         String input = "SELECT convert(convert(TIMESTAMPVALUE, time), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_date(('1970-01-01 ' || to_char(SmallA.TimestampValue, 'HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS') FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT to_char(to_date('1970-01-01 ' || to_char(SmallA.TimestampValue, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS') FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -176,7 +176,7 @@
     }
     @Test public void testConversion7() throws Exception {
         String input = "SELECT convert(convert(STRINGNUM, integer), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_number(SmallA.StringNum)) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT to_char(trunc(to_number(SmallA.StringNum))) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -488,5 +488,32 @@
                 input, output, 
                 TRANSLATOR);
     }
+    
+    @Test public void testLogFunction() throws Exception {
+        String input = "SELECT log(CONVERT(stringkey, INTEGER)) FROM bqt1.smalla"; //$NON-NLS-1$
+        String output = "SELECT ln(trunc(to_number(SmallA.StringKey))) FROM SmallA"; //$NON-NLS-1$
+    
+        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+                input, output, 
+                TRANSLATOR);
+    }
+    
+    @Test public void testLog10Function() throws Exception {
+        String input = "SELECT log10(CONVERT(stringkey, INTEGER)) FROM bqt1.smalla"; //$NON-NLS-1$
+        String output = "SELECT log(10, trunc(to_number(SmallA.StringKey))) FROM SmallA"; //$NON-NLS-1$
+    
+        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+                input, output, 
+                TRANSLATOR);
+    }
+    
+    @Test public void testAliasedFunctions() throws Exception {
+        String input = "SELECT char(CONVERT(stringkey, INTEGER)), lcase(stringkey), ucase(stringkey), ifnull(stringkey, 'x') FROM bqt1.smalla"; //$NON-NLS-1$
+        String output = "SELECT chr(trunc(to_number(SmallA.StringKey))), lower(SmallA.StringKey), upper(SmallA.StringKey), nvl(SmallA.StringKey, 'x') FROM SmallA"; //$NON-NLS-1$
+        
+        MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+                input, output, 
+                TRANSLATOR);
+    }    
 
 }

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestSubstringFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestSubstringFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestSubstringFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -25,16 +25,14 @@
 import java.util.Arrays;
 import java.util.Properties;
 
+import junit.framework.TestCase;
+
 import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
-import org.teiid.connector.jdbc.translator.FunctionModifier;
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 
@@ -53,21 +51,17 @@
         super(name);
     }
 
-    public IExpression helpTestMod(IExpression[] args, String expectedStr) throws Exception {
+    public void helpTestMod(IExpression[] args, String expectedStr) throws Exception {
         IFunction func = LANG_FACTORY.createFunction("substring",  //$NON-NLS-1$
             Arrays.asList(args), TypeFacility.RUNTIME_TYPES.STRING);
         
         OracleSQLTranslator trans = new OracleSQLTranslator();
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
 
-        IExpression expr = ((FunctionModifier)trans.getFunctionModifiers().get("substring")).modify(func); //$NON-NLS-1$
-        
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
+        sqlVisitor.append(func);  
         
         assertEquals(expectedStr, sqlVisitor.toString());
-        
-        return expr;
     }
 
     public void testTwoArgs() throws Exception {

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -97,7 +97,7 @@
     }
     @Test public void testConversion6() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, biginteger) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT cast(PARTS.PART_WEIGHT AS numeric) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS numeric(38)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -118,10 +118,18 @@
         helpTestVisitor(getTestVDB(),
             input, 
             output);
+    }
+    @Test public void testConversion8a() throws Exception {
+        String input = "SELECT convert(convert(PART_WEIGHT, boolean), long) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS boolean) AS integer) FROM PARTS";  //$NON-NLS-1$
+
+        helpTestVisitor(getTestVDB(),
+            input, 
+            output);
     }
     @Test public void testConversion9() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, date) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS date) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -129,7 +137,7 @@
     }
     @Test public void testConversion10() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, time) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS time) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -137,7 +145,7 @@
     }
     @Test public void testConversion11() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, timestamp) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS timestamp) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -145,7 +153,7 @@
     }
     @Test public void testConversion12() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT to_char(cast(PARTS.PART_WEIGHT AS time), 'HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -153,7 +161,7 @@
     }
     @Test public void testConversion13() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'YYYY-MM-DD HH24:MI:SS.US') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT to_char(cast(PARTS.PART_WEIGHT AS timestamp), 'YYYY-MM-DD HH24:MI:SS.UF') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -161,7 +169,7 @@
     }
     @Test public void testConversion14() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT to_char(cast(PARTS.PART_WEIGHT AS date), 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -169,7 +177,7 @@
     }
     @Test public void testConversion15() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), date) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS date) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS timestamp) AS date) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -177,7 +185,7 @@
     }
     @Test public void testConversion16() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), time) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS time) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(date_trunc('second', cast(PARTS.PART_WEIGHT AS timestamp)) AS time) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -185,7 +193,7 @@
     }
     @Test public void testConversion17() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, time), timestamp) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_timestamp(to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_WEIGHT AS time) + TIMESTAMP '1970-01-01' FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -193,7 +201,7 @@
     }
     @Test public void testConversion18() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, date), timestamp) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_timestamp(to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS date) AS timestamp) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -201,12 +209,12 @@
     }
     @Test public void testConversion19() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, boolean), string) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean) = TRUE THEN '1' ELSE '0' END FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean) THEN 'true' WHEN not(cast(PARTS.PART_WEIGHT AS boolean)) THEN 'false' END FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
             output);
-    }
+    }
     
     @Test public void testLog() throws Exception {
         String input = "SELECT log(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
@@ -242,7 +250,7 @@
     
     @Test public void testDayOfWeek() throws Exception {
         String input = "SELECT dayofweek(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT (EXTRACT(DOW FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) + 1) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT (EXTRACT(DOW FROM cast(PARTS.PART_WEIGHT AS timestamp)) + 1) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -250,7 +258,7 @@
     }
     @Test public void testDayOfMonth() throws Exception {
         String input = "SELECT dayofmonth(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(DAY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(DAY FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -258,7 +266,7 @@
     }
     @Test public void testDayOfYear() throws Exception {
         String input = "SELECT dayofyear(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(DOY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(DOY FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -266,7 +274,7 @@
     }
     @Test public void testHour() throws Exception {
         String input = "SELECT hour(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(HOUR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(HOUR FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -274,7 +282,7 @@
     }
     @Test public void testMinute() throws Exception {
         String input = "SELECT minute(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(MINUTE FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(MINUTE FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -282,7 +290,7 @@
     }
     @Test public void testMonth() throws Exception {
         String input = "SELECT month(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(MONTH FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(MONTH FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -290,7 +298,7 @@
     }
     @Test public void testQuarter() throws Exception {
         String input = "SELECT quarter(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(QUARTER FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(QUARTER FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -298,7 +306,7 @@
     }
     @Test public void testSecond() throws Exception {
         String input = "SELECT second(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(SECOND FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(SECOND FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -306,7 +314,7 @@
     }
     @Test public void testWeek() throws Exception {
         String input = "SELECT week(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(WEEK FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(WEEK FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -314,7 +322,7 @@
     }
     @Test public void testYear() throws Exception {
         String input = "SELECT year(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(YEAR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT EXTRACT(YEAR FROM cast(PARTS.PART_WEIGHT AS timestamp)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -322,7 +330,7 @@
     }
     @Test public void testDayName() throws Exception {
         String input = "SELECT dayname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Day')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT rtrim(TO_CHAR(cast(PARTS.PART_WEIGHT AS timestamp), 'Day')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -330,7 +338,7 @@
     }
     @Test public void testMonthName() throws Exception {
         String input = "SELECT monthname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Month')) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT rtrim(TO_CHAR(cast(PARTS.PART_WEIGHT AS timestamp), 'Month')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -404,7 +412,7 @@
      */
     @Test public void testLocate() throws Exception {
         String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
-        String output = "SELECT position(cast(SmallA.IntNum AS varchar) in substr('chimp', 1)) FROM SmallA";  //$NON-NLS-1$
+        String output = "SELECT position(cast(SmallA.IntNum AS varchar(4000)) in substr('chimp', 1)) FROM SmallA";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 
@@ -438,7 +446,7 @@
      */
     @Test public void testLocate3() throws Exception {
         String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
-        String output = "SELECT position(cast(SmallA.IntNum AS varchar) in substr('234567890', 1)) FROM SmallA WHERE SmallA.IntKey = 26";  //$NON-NLS-1$
+        String output = "SELECT position(cast(SmallA.IntNum AS varchar(4000)) in substr('234567890', 1)) FROM SmallA WHERE SmallA.IntKey = 26";  //$NON-NLS-1$
 
         MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
                 input, output, 

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -67,7 +67,7 @@
     @Test
     public void testModFunction() throws Exception {
         String input = "SELECT mod(CONVERT(PART_ID, INTEGER), 13) FROM parts"; //$NON-NLS-1$
-        String output = "SELECT (convert(int, PARTS.PART_ID) % 13) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT (cast(PARTS.PART_ID AS int) % 13) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
@@ -87,7 +87,7 @@
     @Test
     public void testDayOfMonthFunction() throws Exception {
         String input = "SELECT dayofmonth(convert(PARTS.PART_ID, date)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT day(convert(datetime, PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT {fn dayofmonth(cast(PARTS.PART_ID AS datetime))} FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -123,5 +123,14 @@
             input, 
             output);        
     }
+    
+    @Test public void testConvert() throws Exception {
+        String input = "select convert(timestampvalue, date), convert(timestampvalue, string), convert(datevalue, string) from bqt1.smalla"; //$NON-NLS-1$
+        String output = "SELECT cast(replace(convert(varchar, SmallA.TimestampValue, 102), '.', '-') AS datetime), convert(varchar, SmallA.TimestampValue, 21), replace(convert(varchar, SmallA.DateValue, 102), '.', '-') FROM SmallA"; //$NON-NLS-1$
+               
+        helpTestVisitor(getBQTVDB(),
+            input, 
+            output);        
+    }
        
 }

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -6,7 +6,7 @@
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
+ * License AS published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  * 
  * This library is distributed in the hope that it will be useful,
@@ -22,21 +22,22 @@
 
 package org.teiid.connector.jdbc.sybase;
 
+import static org.junit.Assert.*;
+
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Timestamp;
 import java.util.Properties;
 
-import org.teiid.connector.jdbc.sybase.SybaseConvertModifier;
-import org.teiid.connector.jdbc.sybase.SybaseSQLTranslator;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
 import org.teiid.connector.language.IExpression;
 import org.teiid.connector.language.IFunction;
 import org.teiid.connector.language.ILanguageFactory;
 import org.teiid.connector.language.ILiteral;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.CommandBuilder;
 import com.metamatrix.cdk.api.EnvironmentUtility;
 import com.metamatrix.common.types.DataTypeManager;
@@ -44,33 +45,24 @@
 
 /**
  */
-public class TestSybaseConvertModifier extends TestCase {
+public class TestSybaseConvertModifier {
 
     private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
-    /**
-     * Constructor for TestSybaseConvertModifier.
-     * @param name
-     */
-    public TestSybaseConvertModifier(String name) {
-        super(name);
+    private static SybaseSQLTranslator trans = new SybaseSQLTranslator();
+    
+    @BeforeClass
+    public static void setup() throws ConnectorException {
+        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
     }
-
+    
     public String helpGetString(IExpression expr) throws Exception {
-        SybaseSQLTranslator trans = new SybaseSQLTranslator();
-        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
-        
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
         sqlVisitor.append(expr);  
-        
         return sqlVisitor.toString();        
     }
 
     private void helpGetString1(IFunction func, String expectedStr) throws Exception {
-        SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
-        assertEquals(expectedStr, helpGetString(expr)); 
+        assertEquals(expectedStr, helpGetString(func)); 
     }
     
     public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
@@ -80,15 +72,12 @@
                 LANG_FACTORY.createLiteral(tgtType, String.class)},
             DataTypeManager.getDataTypeClass(tgtType));
         
-        SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
         assertEquals("Error converting from " + DataTypeManager.getDataTypeName(srcExpression.getType()) + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$ 
-            expectedExpression, helpGetString(expr)); 
+            expectedExpression, helpGetString(func)); 
     }
     
     // original test -- this is not a drop one anymore
-    public void testModDrop() throws Exception {
+    @Test public void testModDrop() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("5", String.class), //$NON-NLS-1$
@@ -96,13 +85,11 @@
             },
             Integer.class);
         
-        SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        assertEquals("convert(int, '5')", helpGetString(expr)); //$NON-NLS-1$
+        assertEquals("cast('5' AS int)", helpGetString(func)); //$NON-NLS-1$
     }
 
-    /********************Beginning of convert(INPUT, date) ******************/
-    public void testStringToDate() throws Exception {
+    /********************Beginning of cast(date AS INPUT) ******************/
+    @Test public void testStringToDate() throws Exception {
         String dateStr = "2003-12-31"; //$NON-NLS-1$
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -110,13 +97,10 @@
                 LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
             java.sql.Date.class);
         
-        SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
-        IExpression expr = mod.modify(func);
-        
-        assertEquals("convert(datetime, '2003-12-31')", helpGetString(expr)); //$NON-NLS-1$
+        assertEquals("cast('2003-12-31' AS datetime)", helpGetString(func)); //$NON-NLS-1$
     }
     
-    public void testTimestampToDate() throws Exception {
+    @Test public void testTimestampToDate() throws Exception {
         ILiteral c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class); 
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -124,12 +108,12 @@
                 LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
             java.sql.Date.class);
         
-        helpGetString1(func,  "convert(datetime, convert(varchar, {ts'1989-03-03 07:08:12.000099999'}, 109))");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(stuff(stuff(convert(varchar, {ts'1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)");  //$NON-NLS-1$
     }
     
-    /********************END of convert(INPUT, date) ******************/
-    /********************Beginning of convert(INPUT, time) ******************/
-    public void testStringToTime() throws Exception {
+    /********************END of cast(date AS INPUT) ******************/
+    /********************Beginning of cast(time AS INPUT) ******************/
+    @Test public void testStringToTime() throws Exception {
         String timeStr = "12:08:07"; //$NON-NLS-1$
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -137,10 +121,10 @@
                 LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
             java.sql.Time.class);
         
-        helpGetString1(func,  "convert(datetime, '12:08:07')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12:08:07' AS datetime)");  //$NON-NLS-1$
     }
     
-    public void testTimestampToTime() throws Exception {
+    @Test public void testTimestampToTime() throws Exception {
         ILiteral c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class); 
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -148,12 +132,12 @@
                 LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
             java.sql.Time.class);
         
-        helpGetString1(func,  "convert(datetime, convert(varchar, {ts'1989-03-03 07:08:12.000099999'}, 108))");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('1970-01-01 ' + convert(varchar, {ts'1989-03-03 07:08:12.0'}, 8) AS datetime)");  //$NON-NLS-1$
     }
-    /********************END of convert(INPUT, time) ******************/
+    /********************END of cast(time AS INPUT) ******************/
     
-    /********************Beginning of convert(INPUT, timestamp) ******************/
-    public void testStringToTimestamp() throws Exception {
+    /********************Beginning of cast(timestamp AS INPUT) ******************/
+    @Test public void testStringToTimestamp() throws Exception {
         String timestampStr = "1989-07-09 12:08:07"; //$NON-NLS-1$
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -161,52 +145,42 @@
                 LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
             java.sql.Timestamp.class);
         
-        helpGetString1(func,  "convert(datetime, '1989-07-09 12:08:07')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('1989-07-09 12:08:07' AS datetime)");  //$NON-NLS-1$
     }
     
-    public void testTimeToTimestamp() throws Exception {
+    @Test public void testTimeToTimestamp() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(TimestampUtil.createTime(12, 2, 3), java.sql.Time.class), 
                 LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
             java.sql.Timestamp.class);
         
-        helpGetString1(func,  "convert(datetime, {ts'1900-01-01 12:02:03'})");  //$NON-NLS-1$
+        helpGetString1(func,  "{ts'1970-01-01 12:02:03'}");  //$NON-NLS-1$
     }
         
-    public void testDateToTimestamp() throws Exception {
+    @Test public void testDateToTimestamp() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(TimestampUtil.createDate(89, 2, 3), java.sql.Date.class), 
                 LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
             java.sql.Timestamp.class);
         
-        helpGetString1(func,  "convert(datetime, {d'1989-03-03'})");  //$NON-NLS-1$
+        helpGetString1(func,  "{d'1989-03-03'}");  //$NON-NLS-1$
     }
-    /********************END of convert(INPUT, timestamp) ******************/
+    /********************END of cast(timestamp AS INPUT) ******************/
 
-    /*****************Beginning of convert(input, string)******************/
-    public void testBooleanToStringa() throws Exception {
+    /*****************Beginning of cast(string AS input)******************/
+    @Test public void testBooleanToStringa() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                 LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
             String.class);
 
-        helpGetString1(func,  "convert(varchar, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 'false' WHEN 1 IS NOT NULL THEN 'true' END");  //$NON-NLS-1$
     }
     
-    public void testBooleanToStringb() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
-            new IExpression[] { 
-                LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
-                LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
-            String.class);
-
-        helpGetString1(func,  "convert(varchar, 0)");  //$NON-NLS-1$
-    }   
-         
-    public void testTimestampToString() throws Exception {
+    @Test public void testTimestampToString() throws Exception {
         Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -214,10 +188,10 @@
                 LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
             String.class);
 
-        helpGetString1(func,  "convert(varchar, {ts'2003-11-01 12:05:02.0'}, 109)");  //$NON-NLS-1$
+        helpGetString1(func,  "stuff(convert(varchar, {ts'2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')");  //$NON-NLS-1$
     }
     
-    public void testDateToString() throws Exception {
+    @Test public void testDateToString() throws Exception {
         java.sql.Date d = TimestampUtil.createDate(103, 10, 1);
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -225,10 +199,10 @@
                 LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
             String.class);
         
-        helpGetString1(func,  "convert(varchar, {d'2003-11-01'}, 101)");  //$NON-NLS-1$
+        helpGetString1(func,  "stuff(stuff(convert(varchar, {d'2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')");  //$NON-NLS-1$
     } 
     
-    public void testTimeToString() throws Exception {
+    @Test public void testTimeToString() throws Exception {
         java.sql.Time t = TimestampUtil.createTime(3, 10, 1);
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -236,10 +210,10 @@
                 LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
             String.class);
         
-        helpGetString1(func,  "convert(varchar, {ts'1900-01-01 03:10:01'}, 108)");  //$NON-NLS-1$
+        helpGetString1(func,  "convert(varchar, {ts'1970-01-01 03:10:01'}, 8)");  //$NON-NLS-1$
     }    
     
-    public void testBigDecimalToString() throws Exception {
+    @Test public void testBigDecimalToString() throws Exception {
         java.math.BigDecimal m = new java.math.BigDecimal("-123124534.3"); //$NON-NLS-1$
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
@@ -247,798 +221,752 @@
                 LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
             String.class);
         
-        helpGetString1(func,  "convert(varchar, -123124534.3)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(-123124534.3 AS varchar(40))");  //$NON-NLS-1$
     }
-    /***************** End of convert(input, string)******************/
+    /***************** End of cast(string AS input)******************/
     
-    /***************** Beginning of convert(input, char) ************/
-    public void testStringToChar() throws Exception {
+    /***************** Beginning of cast(char AS input) ************/
+    @Test public void testStringToChar() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("12", String.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("char", Character.class)}, //$NON-NLS-1$
         Character.class);
         
-        helpGetString1(func,  "convert(char, '12')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12' AS char(1))");  //$NON-NLS-1$
     }     
-    /***************** End of convert(input, char)******************/
+    /***************** End of cast(char AS input)******************/
      
-    /***************** Beginning of convert(input, boolean) ************/
-    public void testStringToBoolean() throws Exception {
+    /***************** Beginning of cast(boolean AS input) ************/
+    @Test public void testStringToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("true", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 'true')");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 'true' IN ('false', '0') THEN 0 WHEN 'true' IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testByteToBoolean() throws Exception {
+    @Test public void testByteToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testShortToBoolean() throws Exception {
+    @Test public void testShortToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Short((short) 0), Short.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 0)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 0 = 0 THEN 0 WHEN 0 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testIntegerToBoolean() throws Exception {
+    @Test public void testIntegerToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Integer(1), Integer.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testLongToBoolean() throws Exception {
+    @Test public void testLongToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Long(1), Long.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testBigIntegerToBoolean() throws Exception {
+    @Test public void testBigIntegerToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigInteger("1"), java.math.BigInteger.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testFloatToBoolean() throws Exception {
+    @Test public void testFloatToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Float((float)1.0), Float.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testDoubleToBoolean() throws Exception {
+    @Test public void testDoubleToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Double(1.0), Double.class),  
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    public void testBigDecimalToBoolean() throws Exception {
+    @Test public void testBigDecimalToBoolean() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigDecimal("1.0"), java.math.BigDecimal.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
             Boolean.class);
         
-        helpGetString1(func,  "convert(bit, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END");  //$NON-NLS-1$
     } 
     
-    /***************** End of convert(input, boolean)******************/
+    /***************** End of cast(boolean AS input)******************/
     
     
-    /***************** Beginning of convert(input, byte) ************/
-    public void testStringToByte() throws Exception {
+    /***************** Beginning of cast(byte AS input) ************/
+    @Test public void testStringToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("12", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("byte", Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, '12')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12' AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToBytea() throws Exception {
+    @Test public void testBooleanToBytea() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                 LANG_FACTORY.createLiteral("byte", Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "1");  //$NON-NLS-1$
     }  
     
-    public void testBooleanToByteb() throws Exception {
+    @Test public void testShortToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
-                LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
-                LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
-            Byte.class);
-        
-        helpGetString1(func,  "convert(tinyint, 0)");  //$NON-NLS-1$
-    } 
-    
-    public void testShortToByte() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
-            new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Short((short) 123), Short.class),
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 123)");  //$NON-NLS-1$
+        helpGetString1(func,  "123");  //$NON-NLS-1$
     } 
 
-    public void testIntegerToByte() throws Exception {
+    @Test public void testIntegerToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Integer(1232321), Integer.class),
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 1232321)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1232321 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testLongToByte() throws Exception {
+    @Test public void testLongToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Long(1231232341), Long.class),
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 1231232341)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1231232341 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testBigIntegerToByte() throws Exception {
+    @Test public void testBigIntegerToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigInteger("123"), java.math.BigInteger.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 123)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testFloatToByte() throws Exception {
+    @Test public void testFloatToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Float((float) 123.0), Float.class),
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 123.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123.0 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testDoubleToByte() throws Exception {
+    @Test public void testDoubleToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1.0 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testBigDecimalToByte() throws Exception {
+    @Test public void testBigDecimalToByte() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigDecimal("12.3"), java.math.BigDecimal.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("byte",  Byte.class)}, //$NON-NLS-1$
             Byte.class);
         
-        helpGetString1(func,  "convert(tinyint, 12.3)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(12.3 AS smallint)");  //$NON-NLS-1$
     } 
 
-    /***************** End of convert(input, byte)******************/
+    /***************** End of cast(byte AS input)******************/
 
-    /*****************Beginning of convert(input, short)************/
-    public void testStringToShort() throws Exception {
+    /*****************Beginning of cast(short AS input)************/
+    @Test public void testStringToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("123", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("short", Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, '123')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('123' AS smallint)");  //$NON-NLS-1$
     }    
     
-    public void testBooleanToShorta() throws Exception {
+    @Test public void testBooleanToShorta() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                 LANG_FACTORY.createLiteral("short", Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "1");  //$NON-NLS-1$
     }  
     
-    public void testBooleanToShortb() throws Exception {
+    @Test public void testByteToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
-                LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
-                LANG_FACTORY.createLiteral("short", Short.class)}, //$NON-NLS-1$
-            Short.class);
-        
-        helpGetString1(func,  "convert(smallint, 0)");  //$NON-NLS-1$
-    } 
-      
-    public void testByteToShort() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
-            new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Byte((byte) 12), Byte.class),
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 12)");  //$NON-NLS-1$
+        helpGetString1(func,  "12");  //$NON-NLS-1$
     } 
 
-    public void testIntegerToShort() throws Exception {
+    @Test public void testIntegerToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Integer(1232321), Integer.class),
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 1232321)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1232321 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testLongToShort() throws Exception {
+    @Test public void testLongToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Long(1231232341), Long.class),
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 1231232341)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1231232341 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testBigIntegerToShort() throws Exception {
+    @Test public void testBigIntegerToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigInteger("123"), java.math.BigInteger.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 123)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testFloatToShort() throws Exception {
+    @Test public void testFloatToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Float((float) 123.0), Float.class),
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 123.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123.0 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testDoubleToShort() throws Exception {
+    @Test public void testDoubleToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1.0 AS smallint)");  //$NON-NLS-1$
     } 
     
-    public void testBigDecimalToShort() throws Exception {
+    @Test public void testBigDecimalToShort() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigDecimal("12.3"), java.math.BigDecimal.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
             Short.class);
         
-        helpGetString1(func,  "convert(smallint, 12.3)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(12.3 AS smallint)");  //$NON-NLS-1$
     }       
-    /***************** End of convert(input, short)******************/
+    /***************** End of cast(short AS input)******************/
     
-    /***************** Beginning of convert(input, integer) ************/
-    public void testStringToInteger() throws Exception {
+    /***************** Beginning of cast(integer AS input) ************/
+    @Test public void testStringToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("12332", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("integer", Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, '12332')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12332' AS int)");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToIntegera() throws Exception {
+    @Test public void testBooleanToIntegera() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                 LANG_FACTORY.createLiteral("integer", Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 1)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1 AS int)");  //$NON-NLS-1$
     }  
     
-    public void testBooleanToIntegerb() throws Exception {
+    @Test public void testBooleanToIntegerb() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
                 LANG_FACTORY.createLiteral("integer", Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(0 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testByteToInteger() throws Exception {
+    @Test public void testByteToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Byte((byte)12), Byte.class),
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 12)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(12 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testShortToInteger() throws Exception {
+    @Test public void testShortToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Short((short)1243 ), Short.class),
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 1243)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1243 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testLongToInteger() throws Exception {
+    @Test public void testLongToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Long(1231232341), Long.class),
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 1231232341)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1231232341 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testBigIntegerToInteger() throws Exception {
+    @Test public void testBigIntegerToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigInteger("123"), java.math.BigInteger.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 123)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testFloatToInteger() throws Exception {
+    @Test public void testFloatToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Float((float) 123.0), Float.class),
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 123.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(123.0 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testDoubleToInteger() throws Exception {
+    @Test public void testDoubleToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 1.0)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(1.0 AS int)");  //$NON-NLS-1$
     } 
     
-    public void testBigDecimalToInteger() throws Exception {
+    @Test public void testBigDecimalToInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral(new java.math.BigDecimal("12.3"), java.math.BigDecimal.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("integer",  Integer.class)}, //$NON-NLS-1$
             Integer.class);
         
-        helpGetString1(func,  "convert(int, 12.3)");  //$NON-NLS-1$
+        helpGetString1(func,  "cast(12.3 AS int)");  //$NON-NLS-1$
     }       
    
-    /***************** End of convert(input, integer)******************/
+    /***************** End of cast(integer AS input)******************/
     
-    /***************** Beginning of convert(input, long) ************/
-    public void testStringToLong() throws Exception {
+    /***************** Beginning of cast(long AS input) ************/
+    @Test public void testStringToLong() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("12332131413", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("long", Long.class)}, //$NON-NLS-1$
             Long.class);
         
-        helpGetString1(func,  "convert(numeric, '12332131413')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12332131413' AS numeric(19,0))");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToLonga() throws Exception {
+    @Test public void testBooleanToLonga() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), LANG_FACTORY.createLiteral("long", Long.class)}, //$NON-NLS-1$
-            Integer.class);
-
-        helpGetString1(func, "convert(numeric, 1)"); //$NON-NLS-1$
-    }
-
-    public void testBooleanToLongb() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
-            new IExpression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), LANG_FACTORY.createLiteral("long", Long.class)}, //$NON-NLS-1$
             Long.class);
 
-        helpGetString1(func, "convert(numeric, 0)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(1 AS numeric(19,0))"); //$NON-NLS-1$
     }
-   
-    /***************** End of convert(input, long)******************/
+
+    /***************** End of cast(long AS input)******************/
     
-    /***************** Beginning of convert(input, biginteger) ************/
-    public void testStringToBigInteger() throws Exception {
+    /***************** Beginning of cast(biginteger AS input) ************/
+    @Test public void testStringToBigInteger() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("12323143241414", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("biginteger", java.math.BigInteger.class)}, //$NON-NLS-1$
             java.math.BigInteger.class);
         
-        helpGetString1(func,  "convert(numeric, '12323143241414')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('12323143241414' AS numeric(38, 0))");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToBigIntegera() throws Exception {
+    @Test public void testBooleanToBigIntegera() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), LANG_FACTORY.createLiteral("biginteger", java.math.BigInteger.class)}, //$NON-NLS-1$
-            Integer.class);
+            BigInteger.class);
 
-        helpGetString1(func, "convert(numeric, 1)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$
     }
 
-    public void testBooleanToBigIntegerb() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
-            new IExpression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), LANG_FACTORY.createLiteral("biginteger", java.math.BigInteger.class)}, //$NON-NLS-1$
-            java.math.BigInteger.class);
-
-        helpGetString1(func, "convert(numeric, 0)"); //$NON-NLS-1$
-    }
+    /***************** End of cast(biginteger AS input)******************/
     
-    /***************** End of convert(input, biginteger)******************/
-    
-    /***************** Beginning of convert(input, float) ************/
-    public void testStringToFloat() throws Exception {
+    /***************** Beginning of cast(float AS input) ************/
+    @Test public void testStringToFloat() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("123", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("float", Float.class)}, //$NON-NLS-1$
             Float.class);
         
-        helpGetString1(func,  "convert(real, '123')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('123' AS real)");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToFloata() throws Exception {
+    @Test public void testBooleanToFloata() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), 
                 LANG_FACTORY.createLiteral("float", Float.class)}, //$NON-NLS-1$
             Float.class);
 
-        helpGetString1(func, "convert(real, 1)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(1 AS real)"); //$NON-NLS-1$
     }
 
-    public void testBooleanToFloatb() throws Exception {
+    @Test public void testBooleanToFloatb() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), 
                 LANG_FACTORY.createLiteral("float", Float.class)}, //$NON-NLS-1$
             Float.class);
 
-        helpGetString1(func, "convert(real, 0)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(0 AS real)"); //$NON-NLS-1$
     }
     
-    /***************** End of convert(input, float)******************/
+    /***************** End of cast(float AS input)******************/
     
-    /***************** Beginning of convert(input, double) ************/
-    public void testStringToDouble() throws Exception {
+    /***************** Beginning of cast(double AS input) ************/
+    @Test public void testStringToDouble() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("123", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
             Double.class);
         
-        helpGetString1(func,  "convert(float, '123')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('123' AS double precision)");  //$NON-NLS-1$
     } 
     
-    public void testBooleanToDoublea() throws Exception {
+    @Test public void testBooleanToDoublea() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), 
                 LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
             Double.class);
 
-        helpGetString1(func, "convert(float, 1)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(1 AS double precision)"); //$NON-NLS-1$
     }
 
-    public void testBooleanToDoubleb() throws Exception {
+    @Test public void testBooleanToDoubleb() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), 
                 LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
             Double.class);
 
-        helpGetString1(func, "convert(float, 0)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(0 AS double precision)"); //$NON-NLS-1$
     }
     
-    /***************** End of convert(input, double)******************/
+    /***************** End of cast(double AS input)******************/
     
-    /***************** Beginning of convert(input, bigdecimal) ************/
-    public void testStringToBigDecimal() throws Exception {
+    /***************** Beginning of cast(bigdecimal AS input) ************/
+    @Test public void testStringToBigDecimal() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert",  //$NON-NLS-1$
             new IExpression[] { 
                 LANG_FACTORY.createLiteral("123", String.class),  //$NON-NLS-1$
                 LANG_FACTORY.createLiteral("bigdecimal", java.math.BigDecimal.class)}, //$NON-NLS-1$
             java.math.BigDecimal.class);
         
-        helpGetString1(func,  "convert(float, '123')");  //$NON-NLS-1$
+        helpGetString1(func,  "cast('123' AS numeric(38, 19))");  //$NON-NLS-1$
     } 
 
-    public void testBooleanToBigDecimala() throws Exception {
+    @Test public void testBooleanToBigDecimala() throws Exception {
         IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
             new IExpression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), 
                 LANG_FACTORY.createLiteral("bigdecimal", java.math.BigDecimal.class)}, //$NON-NLS-1$
             java.math.BigDecimal.class);
 
-        helpGetString1(func, "convert(float, 1)"); //$NON-NLS-1$
+        helpGetString1(func, "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$
     }
 
-    public void testBooleanToBigDecimalb() throws Exception {
-        IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
-            new IExpression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), 
-                LANG_FACTORY.createLiteral("bigdecimal", java.math.BigDecimal.class)}, //$NON-NLS-1$
-            java.math.BigDecimal.class);
-
-        helpGetString1(func, "convert(float, 0)"); //$NON-NLS-1$
-    }    
-
     // Source = CHAR
     
-    public void testCharToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "convert(varchar, '5')"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testCharToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "'5'"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BOOLEAN
     
-    public void testBooleanToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = 0 THEN 'false' WHEN 1 IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToByte() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToByte() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToShort() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToShort() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "1"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "cast(1 AS int)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "cast(1 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBooleanToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testBooleanToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     // Source = BYTE
     
-    public void testByteToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "cast(1 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testByteToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testByteToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = SHORT
     
-    public void testShortToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "cast(1 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "cast(1 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testShortToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testShortToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = INTEGER
     
-    public void testIntegerToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "cast(1 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "cast(1 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testIntegerToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = LONG
     
-    public void testLongToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "cast(1 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "cast(1 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLongToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testLongToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = BIGINTEGER
     
-    public void testBigIntegerToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "cast(1 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "cast(1 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "cast(1 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "cast(1 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigIntegerToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigIntegerToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // Source = FLOAT
     
-    public void testFloatToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "cast(1.2 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "cast(1.2 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "cast(1.2 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToDouble() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "cast(1.2 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testFloatToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testFloatToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "cast(1.2 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // Source = DOUBLE
     
-    public void testDoubleToString() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToString() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "cast(1.2 AS varchar(40))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "cast(1.2 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "cast(1.2 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "convert(real, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "cast(1.2 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testDoubleToBigDecimal() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testDoubleToBigDecimal() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "cast(1.2 AS numeric(38, 19))"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testBigDecimalToLong() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToLong() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "cast(1.0 AS numeric(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToBigInteger() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToBigInteger() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "cast(1.0 AS numeric(38, 0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToFloat() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "convert(real, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToFloat() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "cast(1.0 AS real)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testBigDecimalToDoublel() throws Exception {
-        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "convert(float, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testBigDecimalToDouble() throws Exception {
+        helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "cast(1.0 AS double precision)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-        
 }

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -58,7 +58,7 @@
         // Convert from sql to objects
         ICommand obj = MetadataFactory.helpTranslate(vdb, input);
         
-        TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans);
+        TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans); //$NON-NLS-1$
 		try {
 			tc.translateCommand(obj);
 		} catch (ConnectorException e) {
@@ -71,8 +71,7 @@
     @Test
     public void testModFunction() {
         String input = "SELECT mod(CONVERT(PART_ID, INTEGER), 13) FROM parts"; //$NON-NLS-1$
-        //String output = "SELECT (PARTS.PART_ID % 13) FROM PARTS";  //$NON-NLS-1$
-        String output = "SELECT (convert(int, PARTS.PART_ID) % 13) FROM PARTS";  //$NON-NLS-1$
+        String output = "SELECT (cast(PARTS.PART_ID AS int) % 13) FROM PARTS";  //$NON-NLS-1$
         
         helpTestVisitor(getTestVDB(),
             input, 
@@ -111,7 +110,7 @@
     @Test
     public void testLengthFunction() {
         String input = "SELECT length(PART_NAME) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT char_length(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT {fn length(PARTS.PART_NAME)} FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -121,7 +120,7 @@
     @Test
     public void testSubstring2ArgFunction() {
         String input = "SELECT substring(PART_NAME, 3) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT substring(PARTS.PART_NAME, 3, char_length(PARTS.PART_NAME)) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT substring(PARTS.PART_NAME, 3, {fn length(PARTS.PART_NAME)}) FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -141,8 +140,7 @@
     @Test
     public void testConvertFunctionInteger() {
         String input = "SELECT convert(PARTS.PART_ID, integer) FROM PARTS"; //$NON-NLS-1$
-        //String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(int, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_ID AS int) FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -152,7 +150,7 @@
     @Test
     public void testConvertFunctionChar() {
         String input = "SELECT convert(PART_NAME, char) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(char, PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_NAME AS char(1)) FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -162,7 +160,7 @@
     @Test
     public void testConvertFunctionBoolean() {
         String input = "SELECT convert(PART_ID, boolean) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(bit, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT CASE WHEN PARTS.PART_ID IN ('false', '0') THEN 0 WHEN PARTS.PART_ID IS NOT NULL THEN 1 END FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -190,7 +188,7 @@
     public void testTimeLiteral() {
         helpTestVisitor(getTestVDB(),
             "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
-            "SELECT {ts'1900-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+            "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
     }
 
     @Test
@@ -211,7 +209,7 @@
     @Test
     public void testConvertFunctionString() throws Exception {
         String input = "SELECT convert(PARTS.PART_ID, integer) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT convert(int, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
+        String output = "SELECT cast(PARTS.PART_ID AS int) FROM PARTS"; //$NON-NLS-1$
     
         helpTestVisitor(getTestVDB(),
             input, 
@@ -221,7 +219,7 @@
     @Test
     public void testNonIntMod() throws Exception {
     	String input = "select mod(intkey/1.5, 3) from bqt1.smalla"; //$NON-NLS-1$
-        String output = "SELECT ((convert(float, SmallA.IntKey) / 1.5) - (floor(((convert(float, SmallA.IntKey) / 1.5) / 3.0)) * 3.0)) FROM SmallA"; //$NON-NLS-1$
+        String output = "SELECT ((cast(SmallA.IntKey AS double precision) / 1.5) - (sign((cast(SmallA.IntKey AS double precision) / 1.5)) * floor(abs(((cast(SmallA.IntKey AS double precision) / 1.5) / 3.0))) * abs(3.0))) FROM SmallA"; //$NON-NLS-1$
                
         helpTestVisitor(getBQTVDB(),
             input, 

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -55,22 +55,20 @@
         super(name);
     }
 
-    public IExpression helpTestMod(IExpression c, String expectedStr, String target) throws Exception {
+    public void helpTestMod(IExpression c, String expectedStr, String target) throws Exception {
         IFunction func = LANG_FACTORY.createFunction(target, 
             Arrays.asList(c),
             Integer.class);
         
         ExtractFunctionModifier mod = new ExtractFunctionModifier ();
-        IExpression expr = mod.modify(func);
         Translator trans = new Translator();
         trans.registerFunctionModifier(target, mod);
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
         
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
 
-        sqlVisitor.append(expr);  
+        sqlVisitor.append(func);  
         assertEquals(expectedStr, sqlVisitor.toString());
-        return expr;
     }
     public void test1() throws Exception {
         ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);

Deleted: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLOCATEFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLOCATEFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLOCATEFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,319 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.jdbc.translator;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.SourceSystemFunctions;
-import org.teiid.connector.language.IExpression;
-import org.teiid.connector.language.IFunction;
-import org.teiid.connector.language.ILanguageFactory;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-
-/**
- * Test <code>LOCATEFunctionModifier</code> by invoking its methods with varying 
- * parameters to validate it performs as designed and expected. 
- */
-public class TestLOCATEFunctionModifier {
-
-    private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
-    /**
-     * Create an expression containing a LOCATE function using <code>args</code> 
-     * and pass it to the <code>Translator</code>'s LOCATE function modifier and 
-     * compare the resulting expression to <code>expectedStr</code>.
-     * 
-     * @param args An array of <code>IExpression</code>'s to use as the 
-     *             arguments to the LOCATE() function
-     * @param expectedStr A string representing the modified expression
-     * @return On success, the modified expression.
-     * @throws Exception
-     */
-    public IExpression helpTestLocate(IExpression[] args, String expectedStr) throws Exception {
-    	return this.helpTestLocate(LocateFunctionModifier.LOCATE, false, args, expectedStr);
-    }
-
-    /**
-     * Create an expression containing a LOCATE function using a function name of 
-     * <code>locateFunctionName</code> with the parameter order of 
-     * <code>parameterOrder</code> and a string index base of 
-     * <code>stringIndexBase</code> and uses the arguments <code>args</code> and 
-     * pass it to the <code>Translator</code>'s LOCATE function modifier and 
-     * compare the resulting expression to <code>expectedStr</code>.
-     *
-     * @param locateFunctionName the name to use for the function modifier
-     * @param parameterOrder an <code>enum</code> value as defined by 
-     *        {@link ParameterOrder} which represents the parameter order to use  
-     *        for the modified LOCATE() function
-     * @param stringIndexBase the string index that represents the first character of a string
-     * @param args an array of <code>IExpression</code>'s to use as the 
-     *             arguments to the LOCATE() function
-     * @param expectedStr A string representing the modified expression
-     * @return On success, the modified expression.
-     * @throws Exception
-     */
-    public IExpression helpTestLocate(final String locateFunctionName, final boolean parameterOrder, IExpression[] args, String expectedStr) throws Exception {
-    	IExpression param1 = null;
-    	IExpression param2 = null;
-    	IExpression param3 = null;
-    	
-    	if (args.length > 0 ) param1 = args[0];
-    	if (args.length > 1 ) param2 = args[1];
-    	if (args.length > 2 ) param3 = args[2];
-    	
-    	IFunction func = null;
-    	
-    	if (param3 != null) {
-    		func = LANG_FACTORY.createFunction(SourceSystemFunctions.LOCATE,
-    	            Arrays.asList(param1, param2, param3), Integer.class);
-    	} else {
-    		func = LANG_FACTORY.createFunction(SourceSystemFunctions.LOCATE,
-    	            Arrays.asList(param1, param2), Integer.class);
-    	}
-
-    	Translator trans = new Translator() {
-			@Override
-			public void initialize(ConnectorEnvironment env)
-					throws ConnectorException {
-				super.initialize(env);
-				registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), locateFunctionName, parameterOrder));
-			}
-    	};
-    	
-        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
-
-        IExpression expr = trans.getFunctionModifiers().get(SourceSystemFunctions.LOCATE).modify(func);
-        
-        SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
-        
-        assertEquals("Modified function does not match", expectedStr, sqlVisitor.toString()); //$NON-NLS-1$
-        
-        return expr;
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str) using constants for both parameters 
-     * returns LOCATE(search_str, source_str). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed without specifying a 
-     * function name or parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifySimple() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
-        };
-        // default / default
-        helpTestLocate(args, "LOCATE('a', 'abcdefg')"); //$NON-NLS-1$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str) using constants for both parameters 
-     * returns locate(search_str, source_str). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying a function  
-     * name of locate but no parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifySimple2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
-        };
-        // locate / default
-        helpTestLocate("locate", false, args, "locate('a', 'abcdefg')"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str) using constants for both parameters 
-     * returns INSTR(source_str, search_str). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying a function  
-     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}. 
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifySimple3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
-        };
-        // INSTR / SOURCE_SEARCH_INDEX
-        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a')"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str) using constants for both parameters 
-     * returns locate(search_str, source_str). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying a function  
-     * name of locate and a parameter order of {@link ParameterOrder#DEFAULT}.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifySimple4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
-        };
-        // locate / DEFAULT
-        helpTestLocate("locate", false, args, "locate('a', 'abcdefg')"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, 1) using constants for all parameters 
-     * returns INSTR(source_str, search_str, 1). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying a function  
-     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithStartIndex() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(1, Integer.class)
-        };
-        // INSTR / SOURCE_SEARCH_INDEX
-        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a', 1)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, 4) using constants for all parameters 
-     * returns LOCATE(search_str, source_str, 5). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying no function  
-     * name or parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithStartIndex2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(4, Integer.class)
-        };
-        // default / default
-        helpTestLocate(args, "LOCATE('a', 'abcdefg', 4)"); //$NON-NLS-1$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, -5) using constants for all parameters 
-     * returns LOCATE(search_str, source_str, 1). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying no function  
-     * name or parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithStartIndex3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(-5, Integer.class)
-        };
-        // default / default
-        helpTestLocate(args, "LOCATE('a', 'abcdefg', 1)"); //$NON-NLS-1$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, null) using constants for all parameters 
-     * returns LOCATE(search_str, source_str, NULL). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying no function  
-     * name or parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithStartIndex4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(null, Integer.class)
-        };
-        // default / default
-        helpTestLocate(args, "LOCATE('a', 'abcdefg', NULL)"); //$NON-NLS-1$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, e1) using an element for start index 
-     * parameter returns INSTR(source_str, search_str, CASE WHEN e1 < 1 THEN 1 ELSE e1 END). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying a function  
-     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithElementStartIndex() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createElement("e1", null, null, Integer.class) //$NON-NLS-1$
-        };
-        // INSTR / SOURCE_SEARCH_INDEX
-        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a', CASE WHEN e1 < 1 THEN 1 ELSE e1 END)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
-     * to LOCATE(search_str, source_str, e1) using an element for start index 
-     * parameter returns LOCATE(search_str, source_str, CASE WHEN e1 < 0 THEN 0 ELSE e1 END). 
-     * <p>
-     * {@link LocateFunctionModifier} will be constructed specifying no function  
-     * name and no parameter order.
-     * 
-     * @throws Exception
-     */
-    @Test public void testModifyWithElementStartIndex2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
-                LANG_FACTORY.createElement("e1", null, null, Integer.class) //$NON-NLS-1$
-        };
-        // default / default
-        helpTestLocate(args, "LOCATE('a', 'abcdefg', CASE WHEN e1 < 1 THEN 1 ELSE e1 END)"); //$NON-NLS-1$
-    }
-    
-}

Copied: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLocateFunctionModifier.java (from rev 1276, trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLOCATEFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLocateFunctionModifier.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLocateFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -0,0 +1,315 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.translator;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+import com.metamatrix.cdk.CommandBuilder;
+import com.metamatrix.cdk.api.EnvironmentUtility;
+
+/**
+ * Test <code>LOCATEFunctionModifier</code> by invoking its methods with varying 
+ * parameters to validate it performs as designed and expected. 
+ */
+public class TestLocateFunctionModifier {
+
+    private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
+
+    /**
+     * Create an expression containing a LOCATE function using <code>args</code> 
+     * and pass it to the <code>Translator</code>'s LOCATE function modifier and 
+     * compare the resulting expression to <code>expectedStr</code>.
+     * 
+     * @param args An array of <code>IExpression</code>'s to use as the 
+     *             arguments to the LOCATE() function
+     * @param expectedStr A string representing the modified expression
+     * @return On success, the modified expression.
+     * @throws Exception
+     */
+    public void helpTestLocate(IExpression[] args, String expectedStr) throws Exception {
+    	this.helpTestLocate(LocateFunctionModifier.LOCATE, false, args, expectedStr);
+    }
+
+    /**
+     * Create an expression containing a LOCATE function using a function name of 
+     * <code>locateFunctionName</code> with the parameter order of 
+     * <code>parameterOrder</code> and a string index base of 
+     * <code>stringIndexBase</code> and uses the arguments <code>args</code> and 
+     * pass it to the <code>Translator</code>'s LOCATE function modifier and 
+     * compare the resulting expression to <code>expectedStr</code>.
+     *
+     * @param locateFunctionName the name to use for the function modifier
+     * @param parameterOrder an <code>enum</code> value as defined by 
+     *        {@link ParameterOrder} which represents the parameter order to use  
+     *        for the modified LOCATE() function
+     * @param stringIndexBase the string index that represents the first character of a string
+     * @param args an array of <code>IExpression</code>'s to use as the 
+     *             arguments to the LOCATE() function
+     * @param expectedStr A string representing the modified expression
+     * @return On success, the modified expression.
+     * @throws Exception
+     */
+    public void helpTestLocate(final String locateFunctionName, final boolean parameterOrder, IExpression[] args, String expectedStr) throws Exception {
+    	IExpression param1 = null;
+    	IExpression param2 = null;
+    	IExpression param3 = null;
+    	
+    	if (args.length > 0 ) param1 = args[0];
+    	if (args.length > 1 ) param2 = args[1];
+    	if (args.length > 2 ) param3 = args[2];
+    	
+    	IFunction func = null;
+    	
+    	if (param3 != null) {
+    		func = LANG_FACTORY.createFunction(SourceSystemFunctions.LOCATE,
+    	            Arrays.asList(param1, param2, param3), Integer.class);
+    	} else {
+    		func = LANG_FACTORY.createFunction(SourceSystemFunctions.LOCATE,
+    	            Arrays.asList(param1, param2), Integer.class);
+    	}
+
+    	Translator trans = new Translator() {
+			@Override
+			public void initialize(ConnectorEnvironment env)
+					throws ConnectorException {
+				super.initialize(env);
+				registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), locateFunctionName, parameterOrder));
+			}
+    	};
+    	
+        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
+
+        SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
+        sqlVisitor.append(func);  
+        
+        assertEquals("Modified function does not match", expectedStr, sqlVisitor.toString()); //$NON-NLS-1$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str) using constants for both parameters 
+     * returns LOCATE(search_str, source_str). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed without specifying a 
+     * function name or parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifySimple() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
+        };
+        // default / default
+        helpTestLocate(args, "LOCATE('a', 'abcdefg')"); //$NON-NLS-1$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str) using constants for both parameters 
+     * returns locate(search_str, source_str). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying a function  
+     * name of locate but no parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifySimple2() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
+        };
+        // locate / default
+        helpTestLocate("locate", false, args, "locate('a', 'abcdefg')"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str) using constants for both parameters 
+     * returns INSTR(source_str, search_str). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying a function  
+     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}. 
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifySimple3() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
+        };
+        // INSTR / SOURCE_SEARCH_INDEX
+        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a')"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str) using constants for both parameters 
+     * returns locate(search_str, source_str). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying a function  
+     * name of locate and a parameter order of {@link ParameterOrder#DEFAULT}.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifySimple4() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class) //$NON-NLS-1$
+        };
+        // locate / DEFAULT
+        helpTestLocate("locate", false, args, "locate('a', 'abcdefg')"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, 1) using constants for all parameters 
+     * returns INSTR(source_str, search_str, 1). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying a function  
+     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithStartIndex() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral(1, Integer.class)
+        };
+        // INSTR / SOURCE_SEARCH_INDEX
+        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a', 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, 4) using constants for all parameters 
+     * returns LOCATE(search_str, source_str, 5). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying no function  
+     * name or parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithStartIndex2() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral(4, Integer.class)
+        };
+        // default / default
+        helpTestLocate(args, "LOCATE('a', 'abcdefg', 4)"); //$NON-NLS-1$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, -5) using constants for all parameters 
+     * returns LOCATE(search_str, source_str, 1). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying no function  
+     * name or parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithStartIndex3() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral(-5, Integer.class)
+        };
+        // default / default
+        helpTestLocate(args, "LOCATE('a', 'abcdefg', 1)"); //$NON-NLS-1$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, null) using constants for all parameters 
+     * returns LOCATE(search_str, source_str, NULL). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying no function  
+     * name or parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithStartIndex4() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral(null, Integer.class)
+        };
+        // default / default
+        helpTestLocate(args, "LOCATE('a', 'abcdefg', NULL)"); //$NON-NLS-1$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, e1) using an element for start index 
+     * parameter returns INSTR(source_str, search_str, CASE WHEN e1 < 1 THEN 1 ELSE e1 END). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying a function  
+     * name of INSTR and a parameter order of {@link ParameterOrder#SOURCE_SEARCH_INDEX}.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithElementStartIndex() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createElement("e1", null, null, Integer.class) //$NON-NLS-1$
+        };
+        // INSTR / SOURCE_SEARCH_INDEX
+        helpTestLocate("INSTR", true, args, "INSTR('abcdefg', 'a', CASE WHEN e1 < 1 THEN 1 ELSE e1 END)"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Test {@link LocateFunctionModifier#modify(IFunction)} to validate a call 
+     * to LOCATE(search_str, source_str, e1) using an element for start index 
+     * parameter returns LOCATE(search_str, source_str, CASE WHEN e1 < 0 THEN 0 ELSE e1 END). 
+     * <p>
+     * {@link LocateFunctionModifier} will be constructed specifying no function  
+     * name and no parameter order.
+     * 
+     * @throws Exception
+     */
+    @Test public void testModifyWithElementStartIndex2() throws Exception {
+        IExpression[] args = new IExpression[] {
+                LANG_FACTORY.createLiteral("a", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createLiteral("abcdefg", String.class), //$NON-NLS-1$
+                LANG_FACTORY.createElement("e1", null, null, Integer.class) //$NON-NLS-1$
+        };
+        // default / default
+        helpTestLocate(args, "LOCATE('a', 'abcdefg', CASE WHEN e1 < 1 THEN 1 ELSE e1 END)"); //$NON-NLS-1$
+    }
+    
+}


Property changes on: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestLocateFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -24,9 +24,7 @@
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.List;
 import java.util.Properties;
 
 import junit.framework.TestCase;
@@ -69,8 +67,8 @@
      * @return On success, the modified expression.
      * @throws Exception
      */
-    public IExpression helpTestMod(IExpression[] args, String expectedStr) throws Exception {
-    	return this.helpTestMod(null, null, args, expectedStr);
+    public void helpTestMod(IExpression[] args, String expectedStr) throws Exception {
+    	this.helpTestMod("MOD", args, expectedStr); //$NON-NLS-1$
     }
 
     /**
@@ -81,59 +79,16 @@
      * expression to <code>expectedStr</code>.
      *
      * @param modFunctionName the name to use for the function modifier
-     * @param supportedTypes a list of types that the mod function should support
      * @param args an array of <code>IExpression</code>'s to use as the 
      *             arguments to the MOD() function
      * @param expectedStr A string representing the modified expression
      * @return On success, the modified expression.
      * @throws Exception
      */
-    public IExpression helpTestMod(final String modFunctionName, final List<Class<?>> supportedTypes, IExpression[] args, String expectedStr) throws Exception {
-    	IExpression param1 = null;
-    	IExpression param2 = null;
+    public void helpTestMod(final String modFunctionName, IExpression[] args, String expectedStr) throws Exception {
+    	IExpression param1 = args[0];
+    	IExpression param2 = args[1];
     	
-    	if (args.length < 2) {
-    		param2 = LANG_FACTORY.createLiteral(null, Short.class);
-    		if (args.length < 1) {
-        		param1 = LANG_FACTORY.createLiteral(null, Short.class);
-    		} else {
-    			param1 = args[0];
-    		}
-    	} else {
-    		param1 = args[0];
-    		param2 = args[1];
-    	}
-    	
-    	if ( !param1.getType().equals(param2.getType()) ) {
-    		if (param2.getType().equals(BigDecimal.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(BigDecimal.class)) {
-    			param2.setType(param1.getType());
-    		} else if (param2.getType().equals(BigInteger.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(BigInteger.class)) {
-    			param2.setType(param1.getType());
-    		} else if (param2.getType().equals(Float.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(Float.class)) {
-    			param2.setType(param1.getType());
-    		} else if (param2.getType().equals(Long.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(Long.class)) {
-    			param2.setType(param1.getType());
-    		} else if (param2.getType().equals(Integer.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(Integer.class)) {
-    			param2.setType(param1.getType());
-    		} else if (param2.getType().equals(Short.class)) {
-    			param1.setType(param2.getType());
-    		} else if (param1.getType().equals(Short.class)) {
-    			param2.setType(param1.getType());
-    		} else {
-    			throw new IllegalArgumentException("Parameters must be of numeric types"); //$NON-NLS-1$
-    		}
-    	}
-
     	IFunction func = LANG_FACTORY.createFunction(modFunctionName,
             Arrays.asList(param1, param2), param1.getType());
 
@@ -142,157 +97,20 @@
 			public void initialize(ConnectorEnvironment env)
 					throws ConnectorException {
 				super.initialize(env);
-				if (modFunctionName == null) {
-					registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory()));
-				} else {
-					registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory(), modFunctionName, supportedTypes));
-				}
+				registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(modFunctionName, getLanguageFactory()));
 			}
     	};
     	
         trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
 
-        IExpression expr = trans.getFunctionModifiers().get(SourceSystemFunctions.MOD).modify(func);
-        
         SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
+        sqlVisitor.append(func);  
         
         assertEquals("Modified function does not match", expectedStr, sqlVisitor.toString()); //$NON-NLS-1$
-        
-        return expr;
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Short} constants for both parameters returns MOD(x,y). 
-     * {@link ModFunctionModifier} will be constructed without specifying a 
-     * function name or a supported type list.
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // default / default
-        helpTestMod(args, "MOD(10, 6)"); //$NON-NLS-1$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Short} constants for both parameters returns MOD(x,y). 
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "MOD" but without a supported type list.
-     *  
-     * @throws Exception
-     */
-    public void testTwoShortConst2() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // mod / default 
-        helpTestMod("MOD", null, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Short} constants for both parameters returns MOD(x,y). 
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "MOD" and a supported type list which contains {@link Short}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst3() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Short} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contains {@link Short}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // mod / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("MOD", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Short} constants for both parameters returns (x % y).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "%" and no supported type list. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst5() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // % / default 
-        helpTestMod("%", null, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Short} constants for both parameters returns (x % y).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "%" and a supported type list which contains {@link Short}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst6() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Short} constants for both parameters returns 
-     * (10 - (TRUNC((10 / 6), 0) * 6)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list does not 
-     * contain {@link Short}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoShortConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Short((short) 10), Short.class),
-            LANG_FACTORY.createLiteral(new Short((short) 6), Short.class)           
-        };
-        // % / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("%", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(x,y) using {@link Integer} constants for both parameters returns 
      * MOD(x,y).  {@link ModFunctionModifier} will be constructed without 
      * specifying a function name or a supported type list.
@@ -322,7 +140,7 @@
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
         };
         // mod / default 
-        helpTestMod("MOD", null, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -338,34 +156,11 @@
                 LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
         };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("MOD", typeList, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Integer} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contain {@link Integer}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoIntConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
-                LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
-        };
-        // mod / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * x % y using {@link Integer} constants for both parameters returns (x % y).  
      * {@link ModFunctionModifier} will be constructed with a function name of 
      * "%" and no supported type list. 
@@ -377,8 +172,7 @@
         		LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
         };
-        // % / default 
-        helpTestMod("%", null, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -394,34 +188,11 @@
                 LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
         };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("%", typeList, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Integer} constants for both parameters returns 
-     * (10 - (TRUNC((10 / 6), 0) * 6)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list that 
-     * does not contain {@link Integer}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoIntConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-            LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
-            LANG_FACTORY.createLiteral(new Integer(6), Integer.class)           
-        };
-        // % / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(x,y) using {@link Long} constants for both parameters returns 
      * MOD(x,y).  {@link ModFunctionModifier} will be constructed without 
      * specifying a function name or a supported type list.
@@ -433,7 +204,6 @@
                 LANG_FACTORY.createLiteral(new Long(10), Long.class),
                 LANG_FACTORY.createLiteral(new Long(6), Long.class)           
         };
-        // default / default
         helpTestMod(args, "MOD(10, 6)"); //$NON-NLS-1$
     }
 
@@ -450,8 +220,7 @@
                 LANG_FACTORY.createLiteral(new Long(10), Long.class),
                 LANG_FACTORY.createLiteral(new Long(6), Long.class)           
         };
-        // mod / default 
-        helpTestMod("MOD", null, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -467,34 +236,11 @@
                 LANG_FACTORY.createLiteral(new Long(10), Long.class),
                 LANG_FACTORY.createLiteral(new Long(6), Long.class)           
         };
-        // mod / Long
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Long.class);
-        helpTestMod("MOD", typeList, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Long} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contain {@link Long}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoLongConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Long(10), Long.class),
-                LANG_FACTORY.createLiteral(new Long(6), Long.class)           
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * x % y using {@link Long} constants for both parameters returns (x % y).  
      * {@link ModFunctionModifier} will be constructed with a function name of 
      * "%" and no supported type list. 
@@ -506,8 +252,7 @@
                 LANG_FACTORY.createLiteral(new Long(10), Long.class),
                 LANG_FACTORY.createLiteral(new Long(6), Long.class)           
         };
-        // % / default 
-        helpTestMod("%", null, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -523,34 +268,11 @@
                 LANG_FACTORY.createLiteral(new Long(10), Long.class),
                 LANG_FACTORY.createLiteral(new Long(6), Long.class)           
         };
-        // % / Long
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Long.class);
-        helpTestMod("%", typeList, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Long} constants for both parameters returns 
-     * (10 - (TRUNC((10 / 6), 0) * 6)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list that 
-     * does not contain {@link Long}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoLongConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Long(10), Long.class),
-                LANG_FACTORY.createLiteral(new Long(6), Long.class)           
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(x,y) using {@link Float} constants for both parameters returns 
      * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
      * constructed without specifying a function name or a supported type list.
@@ -562,125 +284,11 @@
                 LANG_FACTORY.createLiteral(new Float(10), Float.class),
                 LANG_FACTORY.createLiteral(new Float(6), Float.class)           
         };
-        // default / default
-        helpTestMod(args, "(10.0 - (TRUNC((10.0 / 6.0), 0) * 6.0))"); //$NON-NLS-1$
+        helpTestMod(args, "(10.0 - (sign(10.0) * floor(abs((10.0 / 6.0))) * abs(6.0)))"); //$NON-NLS-1$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Float} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" but without a supported type 
-     * list.
-     *  
-     * @throws Exception
-     */
-    public void testTwoFloatConst2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // mod / default 
-        helpTestMod("MOD", null, args, "(10.0 - (TRUNC((10.0 / 6.0), 0) * 6.0))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Float} constants for both parameters returns 
-     * MOD(x,y).  {@link ModFunctionModifier} will be constructed with a 
-     * function name of "MOD" and a supported type list which contains {@link Float}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoFloatConst3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // mod / Float
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Float.class);
-        helpTestMod("MOD", typeList, args, "MOD(10.0, 6.0)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link Float} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contain {@link Float}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoFloatConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(10.0 - (TRUNC((10.0 / 6.0), 0) * 6.0))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Float} constants for both parameters returns  
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and no supported type list. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoFloatConst5() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // % / default 
-        helpTestMod("%", null, args, "(10.0 - (TRUNC((10.0 / 6.0), 0) * 6.0))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Float} constants for both parameters returns (x % y).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "%" and a supported type list which contains {@link Float}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoFloatConst6() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // % / Float
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Float.class);
-        helpTestMod("%", typeList, args, "(10.0 % 6.0)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link Float} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list that 
-     * does not contain {@link Float}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoFloatConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(10), Float.class),
-                LANG_FACTORY.createLiteral(new Float(6), Float.class)           
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10.0 - (TRUNC((10.0 / 6.0), 0) * 6.0))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(x,y) using {@link BigInteger} constants for both parameters returns 
      * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
      * constructed without specifying a function name or a supported type list.
@@ -692,125 +300,11 @@
                 LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
         };
-        // default / default
-        helpTestMod(args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$
+        helpTestMod(args, "(10 - (sign(10) * floor(abs((10 / 6))) * abs(6)))"); //$NON-NLS-1$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigInteger} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" but without a supported type 
-     * list.
-     *  
-     * @throws Exception
-     */
-    public void testTwoBigIntConst2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // mod / default 
-        helpTestMod("MOD", null, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigInteger} constants for both parameters returns 
-     * MOD(x,y).  {@link ModFunctionModifier} will be constructed with a 
-     * function name of "MOD" and a supported type list which contains {@link BigInteger}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigIntConst3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // mod / BigInteger
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigInteger.class);
-        helpTestMod("MOD", typeList, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigInteger} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contain {@link BigInteger}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigIntConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigInteger} constants for both parameters returns  
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and no supported type list. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigIntConst5() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // % / default 
-        helpTestMod("%", null, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigInteger} constants for both parameters returns 
-     * (x % y).  {@link ModFunctionModifier} will be constructed with a function 
-     * name of "%" and a supported type list which contains {@link BigInteger}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigIntConst6() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // % / BigInteger
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigInteger.class);
-        helpTestMod("%", typeList, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigInteger} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list that 
-     * does not contain {@link BigInteger}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigIntConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigInteger("10"), BigInteger.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigInteger("6"), BigInteger.class) //$NON-NLS-1$
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(x,y) using {@link BigDecimal} constants for both parameters returns 
      * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
      * constructed without specifying a function name or a supported type list.
@@ -822,125 +316,11 @@
                 LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
         };
-        // default / default
-        helpTestMod(args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$
+        helpTestMod(args, "(10 - (sign(10) * floor(abs((10 / 6))) * abs(6)))"); //$NON-NLS-1$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigDecimal} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" but without a supported type 
-     * list.
-     *  
-     * @throws Exception
-     */
-    public void testTwoBigDecConst2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // mod / default 
-        helpTestMod("MOD", null, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigDecimal} constants for both parameters returns 
-     * MOD(x,y).  {@link ModFunctionModifier} will be constructed with a 
-     * function name of "MOD" and a supported type list which contains {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigDecConst3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // mod / BigDecimal
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigDecimal.class);
-        helpTestMod("MOD", typeList, args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,y) using {@link BigDecimal} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "MOD" and a supported type list which 
-     * does not contain {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigDecConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigDecimal} constants for both parameters returns  
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and no supported type list. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigDecConst5() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // % / default 
-        helpTestMod("%", null, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigDecimal} constants for both parameters returns 
-     * (x % y).  {@link ModFunctionModifier} will be constructed with a function 
-     * name of "%" and a supported type list which contains {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigDecConst6() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // % / BigDecimal
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigDecimal.class);
-        helpTestMod("%", typeList, args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * x % y using {@link BigDecimal} constants for both parameters returns 
-     * (x - (TRUNC((x / y), 0) * x)).  {@link ModFunctionModifier} will be 
-     * constructed with a function name of "%" and a supported type list that 
-     * does not contain {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testTwoBigDecConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) //$NON-NLS-1$
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(10 - (TRUNC((10 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(e1,y) using a {@link Integer} element and a {@link Integer} constant 
      * for parameters returns MOD(e1,y).  {@link ModFunctionModifier} will be 
      * constructed without specifying a function name or a supported type list.
@@ -952,7 +332,6 @@
                 LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
         };
-        // default / default
         helpTestMod(args, "MOD(e1, 6)"); //$NON-NLS-1$
     }
 
@@ -971,7 +350,7 @@
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
         };
         // mod / default 
-        helpTestMod("MOD", null, args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -988,34 +367,11 @@
                 LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
         };
-        // mod / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("MOD", typeList, args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("MOD", args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(e1,y) using a {@link Integer} element and a {@link Integer} constant 
-     * for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "MOD" and a supported type list which does not contain {@link Integer}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneIntElemOneIntConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * e1 % y using a {@link Integer} element and a {@link Integer} constant for 
      * parameters returns (e1 % y).  {@link ModFunctionModifier} will be 
      * constructed with a function name of "%" and no supported type list. 
@@ -1028,7 +384,7 @@
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
         };
         // % / default 
-        helpTestMod("%", null, args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -1045,34 +401,11 @@
                 LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
                 LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
         };
-        // % / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Integer.class);
-        helpTestMod("%", typeList, args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestMod("%", args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
      * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * e1 % y using a {@link Integer} element and a {@link Integer} constant for 
-     * parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "%" and a supported type list that does not contain {@link Integer}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneIntElemOneIntConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
      * MOD(e1,y) using a {@link BigDecimal} element and a {@link BigDecimal} 
      * constant for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
      * {@link ModFunctionModifier} will be constructed without specifying a 
@@ -1086,168 +419,7 @@
                 LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
         };
         // default / default
-        helpTestMod(args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$
+        helpTestMod(args, "(e1 - (sign(e1) * floor(abs((e1 / 6))) * abs(6)))"); //$NON-NLS-1$
     }
 
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(e1,y) using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "MOD" but without a supported type list.
-     *  
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst2() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // mod / default 
-        helpTestMod("MOD", null, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(e1,y) using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns MOD(e1,y).  {@link ModFunctionModifier} 
-     * will be constructed with a function name of "MOD" and a supported type 
-     * list which contains {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst3() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // mod / Integer
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigDecimal.class);
-        helpTestMod("MOD", typeList, args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(e1,y) using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "MOD" and a supported type list which does not contain {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst4() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // mod / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("MOD", typeList, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * e1 % y using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns (e1 % y).  {@link ModFunctionModifier} 
-     * will be constructed with a function name of "%" and no supported type 
-     * list. 
-     * 
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst5() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // % / default 
-        helpTestMod("%", null, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * e1 % y using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns (e1 % y).  {@link ModFunctionModifier} 
-     * will be constructed with a function name of "%" and a supported type list 
-     * which contains {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst6() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // % / BigDecimal
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(BigDecimal.class);
-        helpTestMod("%", typeList, args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * e1 % y using a {@link BigDecimal} element and a {@link BigDecimal} 
-     * constant for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).  
-     * {@link ModFunctionModifier} will be constructed with a function name of 
-     * "%" and a supported type list that does not contain {@link BigDecimal}. 
-     * 
-     * @throws Exception
-     */
-    public void testOneBigDecElemOneBigDecConst7() throws Exception {
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createElement("e1", null, null, BigDecimal.class), //$NON-NLS-1$
-                LANG_FACTORY.createLiteral(new BigDecimal(6), BigDecimal.class)
-        };
-        // % / Short
-        List<Class<?>> typeList = new ArrayList<Class<?>>(1);
-        typeList.add(Short.class);
-        helpTestMod("%", typeList, args, "(e1 - (TRUNC((e1 / 6), 0) * 6))"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to 
-     * MOD(x,e1) using a {@link Float} literal and a {@link Float} element for 
-     * parameters returns (x - (floor((x / e1)) * e1)).  {@link ModFunctionModifier} 
-     * will be constructed with a function name of "MOD" and no supported type 
-     * list.  The test explicitly overrides 
-     * {@link ModFunctionModifier#getQuotientExpression(IExpression)} to produce 
-     * output that uses the floor(z) function. 
-     * 
-     * @throws Exception
-     */
-    public void testOverrideGetQuotient() throws Exception {
-    	final Class<?> dataType = Float.class;
-    	final String modFunctionName = "MOD"; //$NON-NLS-1$
-    	final String expectedStr = "(1000.23 - (floor((1000.23 / e1)) * e1))"; //$NON-NLS-1$
-    	
-        IExpression[] args = new IExpression[] {
-                LANG_FACTORY.createLiteral(new Float(1000.23), dataType),
-                LANG_FACTORY.createElement("e1", null, null, dataType), //$NON-NLS-1$
-        };
-    	IFunction func = LANG_FACTORY.createFunction(modFunctionName, args, dataType);
-
-    	final Translator trans = new Translator() {
-			@Override
-			public void initialize(ConnectorEnvironment env)
-					throws ConnectorException {
-				super.initialize(env);
-				registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory(), modFunctionName, null) {
-					@Override
-					protected IExpression getQuotientExpression(
-							IExpression division) {
-						return getLanguageFactory().createFunction("floor", Arrays.asList(division), division.getType()); //$NON-NLS-1$
-					}
-					
-				});
-			}
-    	};
-
-        trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
-
-        IExpression expr = trans.getFunctionModifiers().get(SourceSystemFunctions.MOD).modify(func);
-        SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor(); 
-        sqlVisitor.append(expr);  
-        assertEquals("Modified function does not match", expectedStr, sqlVisitor.toString()); //$NON-NLS-1$
-    }
 }

Copied: trunk/connectors/connector-jdbc/src/test/resources/PartsSupplierOracle.vdb (from rev 1286, trunk/test-integration/src/test/resources/PartsSupplierOracle.vdb)
===================================================================
(Binary files differ)


Property changes on: trunk/connectors/connector-jdbc/src/test/resources/PartsSupplierOracle.vdb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml	2009-08-30 22:19:06 UTC (rev 1294)
@@ -44,7 +44,7 @@
           </row>
           <row>
             <entry>boolean</entry>
-            <entry>a single bit, or Boolean, with two possible values
+            <entry>a single bit, or Boolean, that can true, false, or null (unknown)
             </entry>
             <entry>java.lang.Boolean</entry>
             <entry>BIT</entry>
@@ -373,37 +373,25 @@
           <tbody>
             <row>
               <entry morerows="2">String</entry>
-              <entry>'true'</entry>
-              <entry>true</entry>
-            </row>
-            <row>
               <entry>'false'</entry>
               <entry>false</entry>
             </row>
             <row>
               <entry>'unknown'</entry>
-              <entry>unknown</entry>
+              <entry>null</entry>
             </row>
             <row>
               <entry>other</entry>
-              <entry>
-              	<emphasis>error</emphasis>
-              </entry>
-            </row>
-            <row>
-              <entry morerows="2">Numeric</entry>
-              <entry>1</entry>
               <entry>true</entry>
             </row>
             <row>
+              <entry morerows="2">Numeric</entry>
               <entry>0</entry>
               <entry>false</entry>
             </row>
             <row>
               <entry>other</entry>
-              <entry>
-                <emphasis>error</emphasis>
-              </entry>
+              <entry>true</entry>
             </row>
           </tbody>
         </tgroup>

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -219,6 +219,9 @@
     }
     
     private void handleError(Throwable t) {
+    	if (t instanceof RuntimeException && t.getCause() != null) {
+    		t = t.getCause();
+    	}
         manager.logSRCCommand(this.requestMsg, this.securityContext, CommandLogMessage.CMD_STATUS_ERROR, -1);
         
         String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -408,7 +408,7 @@
     }
 
     @Test public void testConvertStringBoolean3() throws Exception {
-        helpConvertFail("x", "boolean"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpConvert("x", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     @Test public void testConvertStringBoolean4() throws Exception {

Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1846,12 +1846,7 @@
     	
         helpTestLiteral(expected, expectedType, sql, expectedSql);
     }
-    
-    /** SELECT {b 'xyz'} FROM m.g1 */
-    public void testBooleanLiteralFail() {
-        helpException("SELECT {b 'xyz'} FROM m.g1"); //$NON-NLS-1$
-    }    
-    
+        
 	/** SELECT DISTINCT a FROM g */
 	public void testSelectDistinct(){
 		GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -4430,7 +4430,7 @@
     public void testInsertWithoutColumnsFails1() {
         String sql = "Insert into pm1.g1 values (1, 2, 3, 4)"; //$NON-NLS-1$
         
-        helpResolveException(sql, "Error Code:ERR.003.029.0013 Message:Exception converting value 3 of type class java.lang.Integer to expected type class java.lang.Boolean"); //$NON-NLS-1$
+        helpResolveException(sql, "Error Code:ERR.015.008.0041 Message:Expected value of type 'boolean' but '3' is of type 'integer' and no implicit conversion is available."); //$NON-NLS-1$
     }
     
     public void testInsertWithQueryFails() {

Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -73,8 +73,8 @@
                                                                             "Payload",  //$NON-NLS-1$
                                                                             "ExecutionPayload",  //$NON-NLS-1$            
                                                                             "ConnectionID",   //$NON-NLS-1$
-                                                                            "Connector",
-                                                                            "RequestID", "PartID", "ExecCount");    
+                                                                            "Connector", //$NON-NLS-1$
+                                                                            "RequestID", "PartID", "ExecCount");     //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     /**
      * Constructor for TestSQLConversionVisitor.
      * @param name
@@ -383,53 +383,53 @@
 
         ICommand result =  new LanguageBridgeFactory(metadata).translate(command);
 
-        helpTestVisitorWithCommand("SELECT PARTS.PART_NAME FROM PARTS GROUP BY concat(PARTS.PART_ID, 'a')", result, 
-            false, //$NON-NLS-1$
+        helpTestVisitorWithCommand("SELECT PARTS.PART_NAME FROM PARTS GROUP BY concat(PARTS.PART_ID, 'a')", result,  //$NON-NLS-1$
+            false, 
             false);
     }
     
     public void testPreparedStatementCreationWithUpdate() {
         helpTestVisitor(getTestVDB(),
                         "update parts set part_weight = 'a' where part_weight < 5", //$NON-NLS-1$
-                        "UPDATE PARTS SET PART_WEIGHT = ? WHERE PARTS.PART_WEIGHT < ?",
+                        "UPDATE PARTS SET PART_WEIGHT = ? WHERE PARTS.PART_WEIGHT < ?", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     public void testPreparedStatementCreationWithInsert() {
         helpTestVisitor(getTestVDB(),
                         "insert into parts (part_weight) values (5)", //$NON-NLS-1$
-                        "INSERT INTO PARTS (PART_WEIGHT) VALUES (?)",
+                        "INSERT INTO PARTS (PART_WEIGHT) VALUES (?)", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     public void testPreparedStatementCreationWithSelect() {
         helpTestVisitor(getTestVDB(),
                         "select part_name from parts where part_id not in ('x', 'y') and part_weight < 6", //$NON-NLS-1$
-                        "SELECT PARTS.PART_NAME FROM PARTS WHERE (PARTS.PART_ID NOT IN (?, ?)) AND (PARTS.PART_WEIGHT < ?)",
+                        "SELECT PARTS.PART_NAME FROM PARTS WHERE (PARTS.PART_ID NOT IN (?, ?)) AND (PARTS.PART_WEIGHT < ?)", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     public void testPreparedStatementCreationWithLike() {
         helpTestVisitor(getTestVDB(),
                         "select part_name from parts where part_name like '%foo'", //$NON-NLS-1$
-                        "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_NAME LIKE ?",
+                        "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_NAME LIKE ?", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     /**
      * ideally this should not happen, but to be on the safe side 
      * only the right side should get replaced
      */
-    public void testPreparedStatementCreationWithLeftConstant() {
+    public void defer_testPreparedStatementCreationWithLeftConstant() {
         helpTestVisitor(getTestVDB(),
                         "select part_name from parts where 'x' = 'y'", //$NON-NLS-1$
-                        "SELECT PARTS.PART_NAME FROM PARTS WHERE 1 = ?",
+                        "SELECT PARTS.PART_NAME FROM PARTS WHERE 1 = ?", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     /**
@@ -439,17 +439,17 @@
     public void testPreparedStatementCreationWithFunction() {
         helpTestVisitor(getTestVDB(),
                         "select part_name from parts where concat(part_name, 'x') = concat('y', part_weight)", //$NON-NLS-1$
-                        "SELECT PARTS.PART_NAME FROM PARTS WHERE concat(PARTS.PART_NAME, 'x') = concat('y', PARTS.PART_WEIGHT)",
+                        "SELECT PARTS.PART_NAME FROM PARTS WHERE concat(PARTS.PART_NAME, 'x') = concat('y', PARTS.PART_WEIGHT)", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
     
     public void testPreparedStatementCreationWithCase() {
         helpTestVisitor(getTestVDB(),
                         "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME='a' THEN 'b' ELSE 'c' END", //$NON-NLS-1$
-                        "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME = ? THEN 'b' ELSE 'c' END",
+                        "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME = ? THEN 'b' ELSE 'c' END", //$NON-NLS-1$
                         false,
-                        true); //$NON-NLS-1$
+                        true); 
     }
 
     public void testVisitIDeleteWithComment() throws Exception {

Deleted: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java	2009-08-28 23:08:57 UTC (rev 1293)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java	2009-08-30 22:19:06 UTC (rev 1294)
@@ -1,510 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import static org.junit.Assert.*;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.jdbc.JDBCPropertyNames;
-import org.teiid.connector.jdbc.oracle.OracleSQLTranslator;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
-import org.teiid.connector.language.ICommand;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-
-public class TestOracleSQLConversionVisitor {
-    private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
-    
-    private String getTestVDB() {
-        return UnitTestUtil.getTestDataPath() + "/PartsSupplierOracle.vdb"; //$NON-NLS-1$
-    }
-    
-    private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
-        helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, false);
-    }
-
-    private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
-        helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
-    }
-
-    private void helpTestVisitor(String vdb, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
-        // Convert from sql to objects
-        TranslationUtility util = new TranslationUtility(vdb);
-        ICommand obj =  util.parseCommand(input, correctNaming, true);        
-		this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
-    }
-
-    /** Helper method takes a QueryMetadataInterface impl instead of a VDB filename 
-     * @throws ConnectorException 
-     */
-    private void helpTestVisitor(QueryMetadataInterface metadata, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
-        // Convert from sql to objects
-        CommandBuilder commandBuilder = new CommandBuilder(metadata);
-        ICommand obj = commandBuilder.getCommand(input);
-		this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
-    }
-    
-    private void helpTestVisitor(ICommand obj, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
-
-        
-        // Apply function replacement
-        OracleSQLTranslator translator = new OracleSQLTranslator();
-        Properties p = new Properties();
-        if (dbmsTimeZone != null) {
-        	p.setProperty(JDBCPropertyNames.DATABASE_TIME_ZONE, dbmsTimeZone);
-        }
-        translator.initialize(EnvironmentUtility.createEnvironment(p, false));
-        // Convert back to SQL
-        TranslatedCommand tc = new TranslatedCommand(context, translator);
-        tc.translateCommand(obj);
-        
-        // Check stuff
-        assertEquals("Did not get correct sql", expectedOutput, tc.getSql());             //$NON-NLS-1$
-    }
-    
-    /**
-     * case 3905
-     * as of 5.6 this is handled by the rewriter, but it's possible
-     * that we may bring back source queries with expressions in the group by clause
-     */
-    public void defer_testFunctionsInGroupBy() throws Exception {
-        String input = "SELECT substring(PART_NAME, 2, 1) FROM PARTS Group By substring(PART_NAME, 2, 1)"; //$NON-NLS-1$
-        String output = "SELECT substr(PARTS.PART_NAME, 2, 1) FROM PARTS GROUP BY substr(PARTS.PART_NAME, 2, 1)"; //$NON-NLS-1$
-        
-        helpTestVisitor(getTestVDB(),
-                        input, 
-                        null, output);
-    }
-    
-    /** defect 21775 */
-    @Test public void testDateStuff() throws Exception {
-        String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY datevalue"; //$NON-NLS-1$
-        String output = "SELECT CASE WHEN (CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE con!
 cat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END IS NULL) OR (to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL) THEN NULL ELSE concat(CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FR!
 OM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.D!
 ateValue
) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END, to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
-        
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                        input, 
-                        EMPTY_CONTEXT, null, output);
-    }
-    
-    /**
-     * defect 21775
-     * as of 5.6 this is handled by the rewriter, but it's possible
-     * that we may bring back source queries with expressions in the group by clause
-     */
-
-    public void defer_testDateStuffGroupBy() throws Exception {
-        String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY month(datevalue), dayofmonth(datevalue), year(datevalue)"; //$NON-NLS-1$
-        String output = "SELECT ((CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN ('0' || to_char(EXTRACT(MONTH FROM SmallA.DateValue))) ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END || CASE WHEN TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')) < 10 THEN ('0' || to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')))) ELSE to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) END) || to_char(EXTRACT(YEAR FROM SmallA.DateValue))), SUM(SmallA.IntKey) FROM SmallA GROUP BY EXTRACT(MONTH FROM SmallA.DateValue), TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')), EXTRACT(YEAR FROM SmallA.DateValue)"; //$NON-NLS-1$
-        
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);
-    }
-    
-    @Test public void testCharFunction() throws Exception {
-        String input = "SELECT char(CONVERT(PART_ID, INTEGER)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT chr(to_number(PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
-        
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }    
-
-    @Test public void testLcaseFunction() throws Exception {
-        String input = "SELECT lcase(PART_NAME) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT lower(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testUcaseFunction() throws Exception {
-        String input = "SELECT ucase(PART_NAME) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT upper(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testIfnullFunction() throws Exception {
-        String input = "SELECT ifnull(PART_NAME, 'x') FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT nvl(PARTS.PART_NAME, 'x') FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testLogFunction() throws Exception {
-        String input = "SELECT log(CONVERT(PART_ID, INTEGER)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT ln(to_number(PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testLog10Function() throws Exception {
-        String input = "SELECT log10(CONVERT(PART_ID, INTEGER)) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT log(10, to_number(PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionInteger() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, integer) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_number(PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
-    
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionChar() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, char) FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionBoolean() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, boolean) FROM PARTS"; //$NON-NLS-1$
-        //String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT decode(PARTS.PART_ID, 'true', 1, 'false', 0) FROM PARTS"; //$NON-NLS-1$
-        
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionDate() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, date) FROM PARTS"; //$NON-NLS-1$
-        //String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_date(PARTS.PART_ID, 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionTime() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, time) FROM PARTS"; //$NON-NLS-1$
-        //String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_date(('1970-01-01 ' || to_char(PARTS.PART_ID, 'HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS"; //$NON-NLS-1$ 
-    
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testConvertFunctionTimestamp() throws Exception {
-        String input = "SELECT convert(PARTS.PART_ID, timestamp) FROM PARTS"; //$NON-NLS-1$
-        //String output = "SELECT PARTS.PART_ID FROM PARTS"; //$NON-NLS-1$
-        String output = "SELECT to_timestamp(PARTS.PART_ID, 'YYYY-MM-DD HH24:MI:SS.FF') FROM PARTS"; //$NON-NLS-1$
-               
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-    
-    @Test public void testExtractFunctionTimestamp() throws Exception {
-        String input = "SELECT month(TIMESTAMPVALUE) FROM BQT1.Smalla"; //$NON-NLS-1$
-        String output = "SELECT EXTRACT(MONTH FROM SmallA.TimestampValue) FROM SmallA"; //$NON-NLS-1$
-               
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);
-    }
-
-    @Test public void testAliasedGroup() throws Exception {
-        helpTestVisitor(getTestVDB(),
-            "select y.part_name from parts as y", //$NON-NLS-1$
-            null,
-            "SELECT y.PART_NAME FROM PARTS y"); //$NON-NLS-1$
-    }
-    
-    @Test public void testDateLiteral() throws Exception {
-        helpTestVisitor(getTestVDB(),
-            "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
-            null,
-            "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
-    }
-
-    @Test public void testTimeLiteral() throws Exception {
-        helpTestVisitor(getTestVDB(),
-            "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
-            null,
-            "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
-    }
-
-    @Test public void testTimestampLiteral() throws Exception {
-        helpTestVisitor(getTestVDB(),
-            "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
-            null,
-            "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
-    }
-
-    @Test public void testUnionOrderByWithThreeBranches() throws Exception {
-        helpTestVisitor(getTestVDB(),
-                        "select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
-                        null,
-                        "(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
-                        true); 
-    }
-    
-    @Test public void testUnionOrderBy() throws Exception {
-        helpTestVisitor(getTestVDB(),
-                        "select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
-                        null,
-                        "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
-                        true); 
-    }
-
-    @Test public void testUnionOrderBy2() throws Exception {
-        helpTestVisitor(getTestVDB(),
-                        "select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
-                        null,
-                        "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p NULLS FIRST"); //$NON-NLS-1$
-    }
-
-    @Test public void testUpdateWithFunction() throws Exception {
-        String input = "UPDATE bqt1.smalla SET intkey = intkey + 1"; //$NON-NLS-1$
-        String output = "UPDATE SmallA SET IntKey = (SmallA.IntKey + 1)"; //$NON-NLS-1$
-        
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);
-    }
-    
-
-    /**
-     * Oracle's DUAL table is a pseudo-table; element names cannot be 
-     * fully qualified since the table doesn't really exist nor contain
-     * any columns.  But this requires modeling the DUAL table in 
-     * MM as if it were a real physical table, and also modeling any
-     * columns in the table.  Case 3742
-     * 
-     * @since 4.3
-     */
-    @Test public void testDUAL() throws Exception {
-        String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
-        String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
-               
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);
-    }
-
-    /**
-     * Test Oracle's rownum pseudo-column.  Not a real column, so it can't
-     * be fully-qualified with a table name.  MM requires this column to be
-     * modeled in any table which the user wants to use rownum with.
-     * Case 3739
-     * 
-     * @since 4.3
-     */
-    @Test public void testROWNUM() throws Exception {
-        String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
-        String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
-               
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);        
-    }
-    
-    /**
-     * Test Oracle's rownum pseudo-column.  Not a real column, so it can't
-     * be fully-qualified with a table name.  MM requires this column to be
-     * modeled in any table which the user wants to use rownum with.  Case 3739
-     * 
-     * @since 4.3
-     */
-    @Test public void testROWNUM2() throws Exception {
-        String input = "SELECT part_name FROM parts where rownum < 100"; //$NON-NLS-1$
-        String output = "SELECT PARTS.PART_NAME FROM PARTS WHERE ROWNUM < 100"; //$NON-NLS-1$
-               
-        helpTestVisitor(getTestVDB(),
-            input, 
-            null,
-            output);        
-    }    
-    
-    /**
-     * Case 3744.  Test that an Oracle-specific db hint, delivered as a String via command
-     * payload, is added to the translated SQL.
-     * 
-     * @since 4.3
-     */
-    @Test public void testOracleCommentPayload() throws Exception {
-        String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
-        String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
-               
-        String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
-        ExecutionContext context = new ExecutionContextImpl(null, null, null, null, hint, null, "", null, null, null); //$NON-NLS-1$
-        
-        helpTestVisitor(getTestVDB(),
-            input, 
-            context,
-            null,
-            output,
-            false);        
-    }
-    
-    /**
-     * reproducing this case relies on the name in source for the table being different from
-     * the name
-     */
-    @Test public void testCase3845() throws Exception {
-        
-        String input = "SELECT (DoubleNum * 1.0) FROM BQT1.Smalla"; //$NON-NLS-1$
-        String output = "SELECT (SmallishA.DoubleNum * 1.0) FROM SmallishA"; //$NON-NLS-1$
-
-        FakeMetadataFacade metadata = exampleCase3845();
-
-        helpTestVisitor(metadata, input, EMPTY_CONTEXT, null, output);
-    }
-    
-    /** create fake BQT metadata to test this case, name in source is important */
-    private FakeMetadataFacade exampleCase3845() { 
-        // Create models
-        FakeMetadataObject bqt1 = FakeMetadataFactory.createPhysicalModel("BQT1"); //$NON-NLS-1$
-        FakeMetadataObject bqt1SmallA = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", bqt1); //$NON-NLS-1$
-        bqt1SmallA.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "SmallishA");//$NON-NLS-1$
-        FakeMetadataObject doubleNum = FakeMetadataFactory.createElement("BQT1.SmallA.DoubleNum", bqt1SmallA, DataTypeManager.DefaultDataTypes.DOUBLE, 0); //$NON-NLS-1$
-
-        FakeMetadataStore store = new FakeMetadataStore();
-        store.addObject(bqt1);
-        store.addObject(bqt1SmallA);
-        store.addObject(doubleNum);
-        return new FakeMetadataFacade(store);
-    }
-
-	public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
-		helpTestVisitor(vdb, input, null, expectedOutput);
-	}
-
-    @Test public void testRowLimit2() throws Exception {
-        String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
-        String output = "SELECT * FROM (SELECT SmallA.IntKey FROM SmallA) WHERE ROWNUM <= 100"; //$NON-NLS-1$
-               
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);        
-    }
-    
-    @Test public void testRowLimit3() throws Exception {
-        String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
-        String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50"; //$NON-NLS-1$
-               
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);        
-    }
-            
-    @Test public void testLimitWithNestedInlineView() throws Exception {
-        String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
-        String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey NULLS FIRST) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
-               
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);        
-    }
-    
-    @Test public void testExceptAsMinus() throws Exception {
-        String input = "select intkey, intnum from bqt1.smalla except select intnum, intkey from bqt1.smallb"; //$NON-NLS-1$
-        String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA MINUS SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB"; //$NON-NLS-1$
-               
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
-                input, 
-                EMPTY_CONTEXT, null, output);        
-    }
-    
-    @Test public void testConcat2_useLiteral() throws Exception {
-        String sql = "select concat2(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$       
-        String expected = "SELECT concat(nvl(SmallA.StringNum, ''), '_xx') FROM SmallA"; //$NON-NLS-1$
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
-    }
-
-    @Test public void testConcat2() throws Exception {
-        String sql = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$       
-        String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(nvl(SmallA.StringNum, ''), nvl(SmallA.StringNum, '')) END FROM SmallA"; //$NON-NLS-1$
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
-    }
-    
-    @Test public void testConcat() throws Exception {
-        String sql = "select concat(stringnum, stringkey) from BQT1.Smalla"; //$NON-NLS-1$       
-        String expected = "SELECT CASE WHEN (SmallA.StringNum IS NULL) OR (SmallA.StringKey IS NULL) THEN NULL ELSE concat(SmallA.StringNum, SmallA.StringKey) END FROM SmallA"; //$NON-NLS-1$
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
-    }
-    
-    @Test public void testConcat_withLiteral() throws Exception {
-        String sql = "select stringnum || '1' from BQT1.Smalla"; //$NON-NLS-1$       
-        String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(SmallA.StringNum, '1') END FROM SmallA"; //$NON-NLS-1$
-        helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
-    }
-    
-    @Test public void testRowLimitWithUnionOrderBy() throws Exception {
-        String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
-        String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0 NULLS FIRST"; //$NON-NLS-1$
-               
-        CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
-        ICommand obj = commandBuilder.getCommand(input, true, true);
-		this.helpTestVisitor(obj, EMPTY_CONTEXT, null, output);
-    }
-
-}

Deleted: trunk/test-integration/src/test/resources/PartsSupplierOracle.vdb
===================================================================
(Binary files differ)



More information about the teiid-commits mailing list