Author: li.liang
Date: 2009-05-13 13:45:04 -0400 (Wed, 13 May 2009)
New Revision: 928
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/Translator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
Log:
TEIID-591 Remove optional parenthesis for joins for all but MySql connector.
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-05-13
04:28:31 UTC (rev 927)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2009-05-13
17:45:04 UTC (rev 928)
@@ -300,5 +300,9 @@
protected void appendSetOperation(Operation operation) {
buffer.append(translator.getSetOperationString(operation));
}
-
+
+ @Override
+ protected boolean useParensForJoins() {
+ return translator.useParensForJoins();
+ }
}
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-05-13
04:28:31 UTC (rev 927)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-05-13
17:45:04 UTC (rev 928)
@@ -772,4 +772,12 @@
}
}
+ /**
+ * Set to true to indicate that every branch of a join
+ * should have parenthesis.
+ * @return
+ */
+ public boolean useParensForJoins() {
+ return false;
+ }
}
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-05-13
04:28:31 UTC (rev 927)
+++
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2009-05-13
17:45:04 UTC (rev 928)
@@ -27,6 +27,8 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.mysql.TestMySQLTranslator;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ICommand;
@@ -65,4 +67,22 @@
public void testInsertWithSequnce1() throws Exception {
helpTestVisitor("insert into test.group (e0, e1) values (1, 'x')",
"INSERT INTO group (e0, e1) VALUES (1, 'x')");
}
+
+ public void testJoins() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla inner join bqt1.smallb
on smalla.stringkey=smallb.stringkey cross join bqt1.mediuma"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA INNER JOIN SmallB ON
SmallA.StringKey = SmallB.StringKey CROSS JOIN MediumA"; //$NON-NLS-1$
+
+ TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ public void testJoins2() throws Exception {
+ String input = "select smalla.intkey from bqt1.smalla cross join
(bqt1.smallb cross join bqt1.mediuma)"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA CROSS JOIN (SmallB CROSS
JOIN MediumA)"; //$NON-NLS-1$
+
+ TestMySQLTranslator.helpTestVisitor(MetadataFactory.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
}
Show replies by date