/*
// 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.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2012-2012 Pentaho
// All Rights Reserved.
*/
package mondrian.spi.impl;

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

/**
 * Implementation of {@link mondrian.spi.Dialect} for the MonetDB database.
 *
 * @author pstoellberger
 * @since Nov 10, 2012
 */
public class MonetDbDialect extends JdbcDialectImpl {

    public static final JdbcDialectFactory FACTORY =
        new JdbcDialectFactory(
            MonetDbDialect.class,
            DatabaseProduct.MONETDB);

    /**
     * Creates a LucidDbDialect.
     *
     * @param connection Connection
     *
     * @throws java.sql.SQLException on error
     */
    public MonetDbDialect(Connection connection) throws SQLException {
        super(connection);
    }

    @Override
    public boolean allowsMultipleDistinctSqlMeasures() {
        return false;
    }

    @Override
    public boolean allowsCountDistinct() {
        return false;
    }

    @Override
    public boolean requiresAliasForFromQuery() {
        return true;
    }

    @Override
    public boolean allowsCompoundCountDistinct() {
        return false;
    }

    @Override
    public boolean supportsGroupByExpressions() {
        return false;
    }
}

// End MonetDbDialect.java

@@ -326,16 +326,44 @@
 .impl;%0A%0A
+import mondrian.olap.Util;%0A%0A
 import j
@@ -382,16 +382,16 @@
 ection;%0A
-
 import j
@@ -790,13 +790,13 @@
 s a 
-Lucid
+Monet
 DbDi
@@ -1442,24 +1442,24 @@
 essions() %7B%0A
-
         retu
@@ -1473,16 +1473,358 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public void quoteStringLiteral(StringBuilder buf, String s) %7B%0A        // Go beyond Util.singleQuoteString; also quote backslash, like MySQL.%0A        buf.append('%5C'');%0A        String s0 = Util.replace(s, %22'%22, %22''%22);%0A        String s1 = Util.replace(s0, %22%5C%5C%22, %22%5C%5C%5C%5C%22);%0A        buf.append(s1);%0A        buf.append('%5C'');%0A    %7D
 %0A%7D%0A%0A// E

Fix MonetDB dialect for backslashes in string literals.