
dk.eobjects.metamodel.dialects.PostgresqlQueryRewriter Maven / Gradle / Ivy
The newest version!
/**
* This file is part of MetaModel.
*
* MetaModel is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MetaModel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MetaModel. If not, see .
*/
package dk.eobjects.metamodel.dialects;
import dk.eobjects.metamodel.JdbcDataContextStrategy;
import dk.eobjects.metamodel.query.FromItem;
import dk.eobjects.metamodel.query.Query;
import dk.eobjects.metamodel.schema.Schema;
import dk.eobjects.metamodel.schema.Table;
public class PostgresqlQueryRewriter extends DefaultQueryRewriter implements
IQueryRewriter {
@Override
protected String rewriteFromItem(JdbcDataContextStrategy strategy,
Query query, FromItem item) {
String result = super.rewriteFromItem(strategy, query, item);
Table table = item.getTable();
if (table != null) {
Schema schema = table.getSchema();
if (schema != null) {
String schemaName = schema.getName();
if (schemaName != null) {
result = result.replaceFirst(schemaName, '\"' + schema
.getName() + '\"');
}
}
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy