use of com.cadenzauk.siesta.Dialect in project siesta by cadenzauk.
the class AutoDetectDialect method from.
public static Dialect from(DataSource dataSource) {
try (Connection connection = DataSourceUtil.connection(dataSource)) {
DatabaseMetaData metaData = ConnectionUtil.getMetaData(connection);
String productName = metaData.getDatabaseProductName();
return DIALECTS.stream().filter(x -> x.item1().test(productName)).map(x -> x.item2().get()).findFirst().orElseGet(AnsiDialect::new);
} catch (SQLException e) {
throw new RuntimeSqlException(e);
}
}
use of com.cadenzauk.siesta.Dialect in project siesta by cadenzauk.
the class AutoDetectDialectIntegrationTest method detectedCorrectly.
@Test
void detectedCorrectly() {
Dialect result = AutoDetectDialect.from(dataSource);
assertThat(result, Matchers.instanceOf(dialect.getClass()));
}
Aggregations