001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2008-2009 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.spi.impl;
011
012import mondrian.olap.Util;
013
014import java.sql.*;
015import java.util.List;
016
017/**
018 * Implementation of {@link mondrian.spi.Dialect} for the Apache Derby database.
019 *
020 * @author jhyde
021 * @since Nov 23, 2008
022 */
023public class DerbyDialect extends JdbcDialectImpl {
024
025    public static final JdbcDialectFactory FACTORY =
026        new JdbcDialectFactory(
027            DerbyDialect.class,
028            DatabaseProduct.DERBY);
029
030    /**
031     * Creates a DerbyDialect.
032     *
033     * @param connection Connection
034     */
035    public DerbyDialect(Connection connection) throws SQLException {
036        super(connection);
037    }
038
039    protected void quoteDateLiteral(
040        StringBuilder buf,
041        String value,
042        Date date)
043    {
044        // Derby accepts DATE('2008-01-23') but not SQL:2003 format.
045        buf.append("DATE(");
046        Util.singleQuoteString(value, buf);
047        buf.append(")");
048    }
049
050    public boolean requiresAliasForFromQuery() {
051        return true;
052    }
053
054    public boolean allowsMultipleCountDistinct() {
055        // Derby allows at most one distinct-count per query.
056        return false;
057    }
058
059    public String generateInline(
060        List<String> columnNames,
061        List<String> columnTypes,
062        List<String[]> valueList)
063    {
064        return generateInlineForAnsi(
065            "t", columnNames, columnTypes, valueList, true);
066    }
067
068    public boolean supportsGroupByExpressions() {
069        return false;
070    }
071}
072
073// End DerbyDialect.java