Skip to content

Commit

Permalink
MONDRIAN: Fix for MONDRIAN-605, hsqldb 1.8 fails when using top count…
Browse files Browse the repository at this point in the history
…, order by NULLS FIRST, LAST SQL syntax not supported

[git-p4: depot-paths = "//open/mondrian/": change = 13013]
  • Loading branch information
Will Gorman committed Aug 20, 2009
1 parent 5581131 commit fcae81e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/META-INF/services/mondrian.spi.Dialect
Expand Up @@ -3,6 +3,7 @@ mondrian.spi.impl.Db2Dialect
mondrian.spi.impl.Db2OldAs400Dialect
mondrian.spi.impl.DerbyDialect
mondrian.spi.impl.FirebirdDialect
mondrian.spi.impl.HsqldbDialect
mondrian.spi.impl.InfobrightDialect
mondrian.spi.impl.InformixDialect
mondrian.spi.impl.IngresDialect
Expand Down
1 change: 1 addition & 0 deletions src/main/mondrian/spi/Dialect.java
Expand Up @@ -722,6 +722,7 @@ enum DatabaseProduct {
DB2_AS400,
DB2,
FIREBIRD,
HSQLDB,
INFORMIX,
INFOBRIGHT,
INGRES,
Expand Down
51 changes: 51 additions & 0 deletions src/main/mondrian/spi/impl/HsqldbDialect.java
@@ -0,0 +1,51 @@
/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2009 Pentaho
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.spi.impl;

import java.sql.Connection;
import java.sql.SQLException;

/**
* Implementation of {@link mondrian.spi.Dialect} for the Hsqldb database.
*
* @author wgorman
* @version $Id
* @since Aug 20, 2009
*/
public class HsqldbDialect extends JdbcDialectImpl {

public static final JdbcDialectFactory FACTORY =
new JdbcDialectFactory(
HsqldbDialect.class,
DatabaseProduct.HSQLDB);

/**
* Creates a FirebirdDialect.
*
* @param connection Connection
*/
public HsqldbDialect(Connection connection) throws SQLException {
super(connection);
}

@Override
public String generateOrderItem(
String expr,
boolean nullable,
boolean ascending)
{
if (ascending) {
return expr + " ASC";
} else {
return expr + " DESC";
}
}
}

// End HsqldbDialect.java
2 changes: 2 additions & 0 deletions src/main/mondrian/spi/impl/JdbcDialectImpl.java
Expand Up @@ -859,6 +859,8 @@ public static DatabaseProduct getProduct(
return DatabaseProduct.SYBASE;
} else if (productName.toUpperCase().indexOf("TERADATA") >= 0) {
return DatabaseProduct.TERADATA;
} else if (productName.toUpperCase().indexOf("HSQL") >= 0) {
return DatabaseProduct.HSQLDB;
} else {
return DatabaseProduct.UNKNOWN;
}
Expand Down

0 comments on commit fcae81e

Please sign in to comment.