All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.jdbc.postgresql.PostgreSqlDbContext Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
/************************************************************************
 * © 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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy