mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-19 16:16:45 +00:00
feat(h2): add legacy 2.1 driver
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
sourceSets {
|
||||
main.java.srcDirs = ['src/main/java', '../h2/src/main/java']
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.h2database:h2:2.1.214'
|
||||
}
|
||||
|
||||
tasks.named('shadowJar') {
|
||||
manifest {
|
||||
attributes('Agent-Label': 'H2 2.1 Legacy', 'Main-Class': 'com.dbx.agent.h2legacy.H2LegacyAgent')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.dbx.agent.h2legacy;
|
||||
|
||||
import com.dbx.agent.JsonRpcServer;
|
||||
import com.dbx.agent.h2.H2Agent;
|
||||
|
||||
public final class H2LegacyAgent extends H2Agent {
|
||||
public static void main(String[] args) {
|
||||
new JsonRpcServer(new H2LegacyAgent()).run();
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public final class H2Agent extends AbstractJdbcAgent {
|
||||
public class H2Agent extends AbstractJdbcAgent {
|
||||
private String databaseName = "";
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ NATIVE_ONLY_AGENT_MODULES = {
|
||||
"xugu": "drivers/xugu",
|
||||
}
|
||||
JDBC_ARCHITECTURE_ALLOWLIST = {
|
||||
"h2-legacy": "reuses the H2 agent implementation with an isolated legacy driver version",
|
||||
"access": "custom Access metadata and URL behavior pending migration",
|
||||
"dameng": "custom Dameng metadata and DDL pending migration",
|
||||
"db2": "custom DB2 metadata pending migration",
|
||||
|
||||
@@ -4,7 +4,7 @@ def infrastructureModules = ['common', 'test-support']
|
||||
def driverModules = [
|
||||
'access', 'dameng', 'kingbase', 'vastbase', 'goldendb', 'databend', 'databricks', 'saphana',
|
||||
'teradata', 'vertica', 'firebird', 'exasol', 'oceanbase-oracle', 'gbase8a', 'gbase8s',
|
||||
'bigquery', 'kylin', 'sundb', 'h2', 'snowflake', 'trino', 'hive', 'spark',
|
||||
'bigquery', 'kylin', 'sundb', 'h2', 'h2-legacy', 'snowflake', 'trino', 'hive', 'spark',
|
||||
'db2', 'informix', 'neo4j', 'cassandra', 'mongodb', 'highgo', 'tdengine', 'yashandb', 'oscar',
|
||||
'iris', 'iotdb', 'etcd', 'zookeeper', 'kafka', 'sqlserver-legacy'
|
||||
]
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"gbase8s": "0.1.19",
|
||||
"goldendb": "0.1.30",
|
||||
"h2": "0.1.30",
|
||||
"h2-legacy": "0.1.0",
|
||||
"hive": "0.1.30",
|
||||
"spark": "0.1.2",
|
||||
"informix": "0.1.31",
|
||||
|
||||
@@ -647,6 +647,7 @@ const driverProfiles: Record<
|
||||
},
|
||||
dm: { type: "dameng", port: 5236, user: "SYSDBA", label: "DM (Dameng)", icon: "dm" },
|
||||
h2: { type: "h2", port: 9092, user: "sa", label: "H2", icon: "h2" },
|
||||
"h2-legacy": { type: "h2", port: 9092, user: "sa", label: "H2 2.1 Legacy", icon: "h2" },
|
||||
snowflake: { type: "snowflake", port: 443, user: "", label: "Snowflake", icon: "snowflake" },
|
||||
trino: { type: "trino", port: 8080, user: "", label: "Trino", icon: "trino" },
|
||||
prestosql: { type: "prestosql", port: 8080, user: "", label: "PrestoSQL", icon: "presto" },
|
||||
@@ -3985,6 +3986,30 @@ function openExternalUrl(url: string) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="form.db_type === 'h2'" class="grid grid-cols-4 items-center gap-4">
|
||||
<Label :class="connectionLabelSmallClass">Driver</Label>
|
||||
<div class="col-span-3 flex gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
:variant="form.driver_profile !== 'h2-legacy' ? 'default' : 'outline'"
|
||||
@click="
|
||||
form.driver_profile = 'h2';
|
||||
resetTestState();
|
||||
"
|
||||
>H2 2.3</Button
|
||||
>
|
||||
<Button
|
||||
size="sm"
|
||||
:variant="form.driver_profile === 'h2-legacy' ? 'default' : 'outline'"
|
||||
@click="
|
||||
form.driver_profile = 'h2-legacy';
|
||||
resetTestState();
|
||||
"
|
||||
>H2 2.1 Legacy</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="h2DriverMissing" class="grid grid-cols-4 items-center gap-4">
|
||||
<span />
|
||||
<p class="col-span-3 text-xs text-muted-foreground">
|
||||
|
||||
@@ -36,6 +36,9 @@ const MONGODB_PROFILES: &[AgentDriverProfile] = &[AgentDriverProfile {
|
||||
store_visible: false,
|
||||
}];
|
||||
|
||||
const H2_PROFILES: &[AgentDriverProfile] =
|
||||
&[AgentDriverProfile { profile: "h2-legacy", key: "h2-legacy", label: "H2 2.1 Legacy", store_visible: true }];
|
||||
|
||||
const EXTRA_AGENT_LABELS: &[(&str, &str)] =
|
||||
&[("kafka", "Apache Kafka"), ("sqlserver-legacy", "SQL Server legacy compatibility component")];
|
||||
const EXTRA_DRIVER_STORE_ENTRIES: &[(&str, &str)] =
|
||||
@@ -154,7 +157,7 @@ const AGENT_CATALOG: &[AgentCatalogEntry] = &[
|
||||
store_visible: true,
|
||||
profiles: ORACLE_PROFILES,
|
||||
},
|
||||
AgentCatalogEntry { db_type: DatabaseType::H2, key: "h2", label: "H2", store_visible: true, profiles: &[] },
|
||||
AgentCatalogEntry { db_type: DatabaseType::H2, key: "h2", label: "H2", store_visible: true, profiles: H2_PROFILES },
|
||||
AgentCatalogEntry {
|
||||
db_type: DatabaseType::Snowflake,
|
||||
key: "snowflake",
|
||||
@@ -353,3 +356,16 @@ pub fn label_for_key(agent_key: &str) -> Option<&'static str> {
|
||||
fn entry_for_db_type(db_type: &DatabaseType) -> Option<&'static AgentCatalogEntry> {
|
||||
entries().iter().find(|entry| entry.db_type == *db_type)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn h2_legacy_profile_uses_separate_agent() {
|
||||
assert_eq!(agent_key(&DatabaseType::H2, None), Some("h2"));
|
||||
assert_eq!(agent_key(&DatabaseType::H2, Some("h2")), Some("h2"));
|
||||
assert_eq!(agent_key(&DatabaseType::H2, Some("h2-legacy")), Some("h2-legacy"));
|
||||
assert!(driver_store_entries().any(|(key, label)| key == "h2-legacy" && label == "H2 2.1 Legacy"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user