Author: shawkins
Date: 2011-10-06 13:19:47 -0400 (Thu, 06 Oct 2011)
New Revision: 3536
Added:
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/ingres/TestIngresExecutionFactory.java
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java
Log:
TEIID-1773 fixing the locate modifier
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-10-06
03:13:25 UTC (rev 3535)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-10-06
17:19:47 UTC (rev 3536)
@@ -76,7 +76,7 @@
registerFunctionModifier(SourceSystemFunctions.RAND, new
AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new
AliasModifier("uppercase")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new
AliasModifier("day")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier());
addPushDownFunction(INGRES, "bit_add", INTEGER, INTEGER, INTEGER);
//$NON-NLS-1$
addPushDownFunction(INGRES, "bit_length", INTEGER, INTEGER);
//$NON-NLS-1$
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java 2011-10-06
03:13:25 UTC (rev 3535)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/LocateFunctionModifier.java 2011-10-06
17:19:47 UTC (rev 3536)
@@ -21,28 +21,24 @@
*/
package org.teiid.translator.jdbc.ingres;
-import java.util.Arrays;
import java.util.List;
import org.teiid.language.Expression;
import org.teiid.language.Function;
-import org.teiid.language.LanguageFactory;
-import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.FunctionModifier;
public class LocateFunctionModifier extends FunctionModifier {
- private LanguageFactory languageFactory;
-
- public LocateFunctionModifier(LanguageFactory languageFactory) {
- this.languageFactory = languageFactory;
+ public LocateFunctionModifier() {
}
+
@Override
public List<?> translate(Function function) {
Expression a = function.getParameters().get(0);
Expression b = function.getParameters().get(1);
-
- return Arrays.asList(languageFactory.createFunction("locate", new
Expression[] {b, a}, TypeFacility.RUNTIME_TYPES.INTEGER)); //$NON-NLS-1$
+ function.getParameters().set(0, b);
+ function.getParameters().set(1, a);
+ return null;
}
}
Added:
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/ingres/TestIngresExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/ingres/TestIngresExecutionFactory.java
(rev 0)
+++
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/ingres/TestIngresExecutionFactory.java 2011-10-06
17:19:47 UTC (rev 3536)
@@ -0,0 +1,47 @@
+/*
+ * 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.translator.jdbc.ingres;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+public class TestIngresExecutionFactory {
+
+ private static IngresExecutionFactory TRANSLATOR;
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new IngresExecutionFactory();
+ TRANSLATOR.start();
+ }
+
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT INTKEY FROM BQT1.SmallA WHERE LOCATE(1, INTKEY) = 1 ORDER
BY INTKEY"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE
locate(cast(SmallA.IntKey AS varchar(4000)), '1') = 1 ORDER BY
SmallA.IntKey"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
+ }
+
+}
Property changes on:
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/ingres/TestIngresExecutionFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Show replies by date