Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add preliminary support for Firebird SQL dialect

  • Loading branch information...
commit 1b9d5799c383e428f4758fdfb4c99a2b067de07f 1 parent 08da8d1
cyganiak authored
View
4 src/de/fuberlin/wiwiss/d2rq/sql/BeanCounter.java
@@ -4,8 +4,10 @@
* A class for capturing performance information.
* We grant read/write access to instance variables.
*
+ * TODO: Remove?
+ *
* @author jgarbers
- * @version $Id: BeanCounter.java,v 1.1 2006/09/11 23:22:25 cyganiak Exp $
+ * @version $Id: BeanCounter.java,v 1.2 2010/11/03 18:48:17 cyganiak Exp $
*/
public class BeanCounter implements Cloneable {
View
11 src/de/fuberlin/wiwiss/d2rq/sql/ConnectedDB.java
@@ -27,7 +27,7 @@
* TODO Move all engine-specific code from ConnectedDB to this interface and its implementing classes
*
* @author Richard Cyganiak (richard@cyganiak.de)
- * @version $Id: ConnectedDB.java,v 1.36 2010/01/26 16:15:46 fatorange Exp $
+ * @version $Id: ConnectedDB.java,v 1.37 2010/11/03 18:48:17 cyganiak Exp $
*/
public class ConnectedDB {
private static final Log log = LogFactory.getLog(ConnectedDB.class);
@@ -38,6 +38,8 @@
public static final String MSSQL = "Microsoft SQL Server";
public static final String MSAccess = "Microsoft Access";
public static final String Other = "Other";
+ public static final String Firebird = "Firebird";
+
public static final int TEXT_COLUMN = 1;
public static final int NUMERIC_COLUMN = 2;
public static final int DATE_COLUMN = 3;
@@ -315,7 +317,10 @@ private void ensureDatabaseTypeInitialized() {
this.syntax = new MySQLSyntax();
} else if (productName.indexOf("postgresql") >= 0) {
this.dbType = ConnectedDB.PostgreSQL;
- this.syntax = new SQL92Syntax();
+ this.syntax = new SQL92Syntax(true);
+ } else if (productName.indexOf("firebird") >= 0) {
+ this.dbType = ConnectedDB.Firebird;
+ this.syntax = new SQL92Syntax(false);
} else if (productName.indexOf("oracle") >= 0) {
this.dbType = ConnectedDB.Oracle;
this.syntax = new OracleSyntax();
@@ -327,7 +332,7 @@ private void ensureDatabaseTypeInitialized() {
this.syntax = new MSSQLSyntax();
} else {
this.dbType = ConnectedDB.Other;
- this.syntax = new SQL92Syntax();
+ this.syntax = new SQL92Syntax(true);
}
} catch (SQLException ex) {
throw new D2RQException("Database exception", ex);
View
6 src/de/fuberlin/wiwiss/d2rq/sql/MSSQLSyntax.java
@@ -7,10 +7,14 @@
* and MS Access.
*
* @author Richard Cyganiak (richard@cyganiak.de)
- * @version $Id: MSSQLSyntax.java,v 1.1 2009/09/29 19:56:53 cyganiak Exp $
+ * @version $Id: MSSQLSyntax.java,v 1.2 2010/11/03 18:48:17 cyganiak Exp $
*/
public class MSSQLSyntax extends SQL92Syntax {
+ public MSSQLSyntax() {
+ super(true);
+ }
+
public String getRowNumLimitAsSelectModifier(int limit) {
if (limit == Database.NO_LIMIT) return "";
return "TOP " + limit;
View
6 src/de/fuberlin/wiwiss/d2rq/sql/MySQLSyntax.java
@@ -7,10 +7,14 @@
* This syntax class implements MySQL-compatible SQL syntax.
*
* @author Richard Cyganiak (richard@cyganiak.de)
- * @version $Id: MySQLSyntax.java,v 1.1 2009/09/29 19:56:53 cyganiak Exp $
+ * @version $Id: MySQLSyntax.java,v 1.2 2010/11/03 18:48:17 cyganiak Exp $
*/
public class MySQLSyntax extends SQL92Syntax {
+ public MySQLSyntax() {
+ super(true);
+ }
+
public String getConcatenationExpression(String[] sqlFragments) {
StringBuffer result = new StringBuffer("CONCAT(");
for (int i = 0; i < sqlFragments.length; i++) {
View
8 src/de/fuberlin/wiwiss/d2rq/sql/OracleSyntax.java
@@ -1,6 +1,5 @@
package de.fuberlin.wiwiss.d2rq.sql;
-import de.fuberlin.wiwiss.d2rq.algebra.RelationName;
import de.fuberlin.wiwiss.d2rq.expr.Expression;
import de.fuberlin.wiwiss.d2rq.expr.SQLExpression;
import de.fuberlin.wiwiss.d2rq.map.Database;
@@ -9,13 +8,12 @@
* This syntax class implements MySQL-compatible SQL syntax.
*
* @author Richard Cyganiak (richard@cyganiak.de)
- * @version $Id: OracleSyntax.java,v 1.1 2009/09/29 19:56:53 cyganiak Exp $
+ * @version $Id: OracleSyntax.java,v 1.2 2010/11/03 18:48:17 cyganiak Exp $
*/
public class OracleSyntax extends SQL92Syntax {
- public String getRelationNameAliasExpression(RelationName relationName,
- RelationName aliasName) {
- return quoteRelationName(relationName) + " " + quoteRelationName(aliasName);
+ public OracleSyntax() {
+ super(false);
}
public Expression getRowNumLimitAsExpression(int limit) {
View
16 src/de/fuberlin/wiwiss/d2rq/sql/SQL92Syntax.java
@@ -13,10 +13,20 @@
* can override individual methods to implement different syntax.
*
* @author Richard Cyganiak (richard@cyganiak.de)
- * @version $Id: SQL92Syntax.java,v 1.1 2009/09/29 19:56:53 cyganiak Exp $
+ * @version $Id: SQL92Syntax.java,v 1.2 2010/11/03 18:48:17 cyganiak Exp $
*/
public class SQL92Syntax implements SQLSyntax {
-
+ private boolean useAS;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param useAS Use "Table AS Alias" or "Table Alias" in FROM clauses? In standard SQL, either is fine.
+ */
+ public SQL92Syntax(boolean useAS) {
+ this.useAS = useAS;
+ }
+
public String getConcatenationExpression(String[] sqlFragments) {
StringBuffer result = new StringBuffer();
for (int i = 0; i < sqlFragments.length; i++) {
@@ -30,7 +40,7 @@ public String getConcatenationExpression(String[] sqlFragments) {
public String getRelationNameAliasExpression(RelationName relationName,
RelationName aliasName) {
- return quoteRelationName(relationName) + " AS " + quoteRelationName(aliasName);
+ return quoteRelationName(relationName) + (useAS ? " AS " : " ") + quoteRelationName(aliasName);
}
public String quoteAttribute(Attribute attribute) {
Please sign in to comment.
Something went wrong with that request. Please try again.