com.sap.cds.jdbc.postgresql.PostgreSqlDbContext Maven / Gradle / Ivy
/************************************************************************
* © 2020-2023 SAP SE or an SAP affiliate company. All rights reserved. *
************************************************************************/
package com.sap.cds.jdbc.postgresql;
import java.util.Locale;
import java.util.function.Function;
import com.sap.cds.CdsDataStoreConnector.Capabilities;
import com.sap.cds.DataStoreConfiguration;
import com.sap.cds.jdbc.generic.GenericDbContext;
import com.sap.cds.jdbc.generic.LocaleVariableTableNameResolver;
import com.sap.cds.jdbc.spi.ExceptionAnalyzer;
import com.sap.cds.jdbc.spi.FunctionMapper;
import com.sap.cds.jdbc.spi.PredicateMapper;
import com.sap.cds.jdbc.spi.SessionVariableSetter;
import com.sap.cds.jdbc.spi.StatementResolver;
import com.sap.cds.jdbc.spi.TableNameResolver;
public final class PostgreSqlDbContext extends GenericDbContext {
@Override
public FunctionMapper getFunctionMapper() {
return new PostgreSqlFunctionMapper();
}
@Override
public StatementResolver getStatementResolver() {
return new PostgreSqlStatementResolver();
}
@Override
public ExceptionAnalyzer getExceptionAnalyzer() {
return new PostgreSqlExceptionAnalyzer();
}
public PostgreSqlDbContext(DataStoreConfiguration dataStoreConfiguration) {
super(dataStoreConfiguration);
}
@Override
public Capabilities getCapabilities() {
return new Capabilities() {
@Override
public int timestampPrecision() {
return 6;
}
};
}
@Override
public PredicateMapper getPredicateMapper() {
return new PostgreSqlPredicateMapper();
}
@Override
public SessionVariableSetter getSessionVariableSetter() {
return new PostgreSqlSessionVariableSetter();
}
@Override
public TableNameResolver createTableNameResolver(Locale locale) {
return new LocaleVariableTableNameResolver(this::getSqlMapping, locale);
}
@Override
public Function casing() {
return name -> name.toLowerCase(Locale.US);
}
}