Merge pull request #42815 from nosan
* pr/42815: Polish 'Add support for ClickHouse in `DatabaseDriver` enum' Add support for ClickHouse in `DatabaseDriver` enum Closes gh-42815
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,8 +62,8 @@ class BatchDataSourceScriptDatabaseInitializerTests {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE,
|
||||
names = { "FIREBIRD", "INFORMIX", "JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" })
|
||||
@EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE, names = { "CLICKHOUSE", "FIREBIRD", "INFORMIX",
|
||||
"JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" })
|
||||
void batchSchemaCanBeLocated(DatabaseDriver driver) throws SQLException {
|
||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
BatchProperties properties = new BatchProperties();
|
||||
|
||||
@@ -33,6 +33,13 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("ClickHouse", "0.6.5") {
|
||||
group("com.clickhouse") {
|
||||
modules = [
|
||||
"clickhouse-jdbc"
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Commons Compress", "1.25.0") {
|
||||
group("org.apache.commons") {
|
||||
modules = [
|
||||
|
||||
@@ -22,6 +22,7 @@ dependencies {
|
||||
api("org.springframework:spring-context")
|
||||
|
||||
optional("ch.qos.logback:logback-classic")
|
||||
optional("com.clickhouse:clickhouse-jdbc")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind")
|
||||
optional("com.h2database:h2")
|
||||
optional("com.google.code.gson:gson")
|
||||
|
||||
@@ -205,6 +205,19 @@ public enum DatabaseDriver {
|
||||
return Collections.singleton("tc");
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* ClickHouse.
|
||||
* @since 3.4.0
|
||||
*/
|
||||
CLICKHOUSE("ClickHouse", "com.clickhouse.jdbc.ClickHouseDriver", null, "SELECT 1") {
|
||||
|
||||
@Override
|
||||
protected Collection<String> getUrlPrefixes() {
|
||||
return Arrays.asList("ch", "clickhouse");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private final String productName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -84,6 +84,7 @@ class DatabaseDriverTests {
|
||||
assertThat(DatabaseDriver.fromProductName("Teradata")).isEqualTo(DatabaseDriver.TERADATA);
|
||||
assertThat(DatabaseDriver.fromProductName("Informix Dynamic Server")).isEqualTo(DatabaseDriver.INFORMIX);
|
||||
assertThat(DatabaseDriver.fromProductName("Apache Phoenix")).isEqualTo(DatabaseDriver.PHOENIX);
|
||||
assertThat(DatabaseDriver.fromProductName("ClickHouse")).isEqualTo(DatabaseDriver.CLICKHOUSE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,6 +118,9 @@ class DatabaseDriverTests {
|
||||
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:phoenix:localhost")).isEqualTo(DatabaseDriver.PHOENIX);
|
||||
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:tc:mysql://localhost:3306/sample"))
|
||||
.isEqualTo(DatabaseDriver.TESTCONTAINERS);
|
||||
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:clickhouse://localhost:3306/sample"))
|
||||
.isEqualTo(DatabaseDriver.CLICKHOUSE);
|
||||
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:ch://localhost:3306/sample")).isEqualTo(DatabaseDriver.CLICKHOUSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user