fix(databend): enable editing and procedures
This commit is contained in:
1 parent
1debfef284
commit
3ee2514d07
10 files changed
+147
-9
No files matched your search
@@ -10,6 +10,7 @@ export interface DatabaseObjectCapabilities {
|
|||||||
|
|
||||||
const TABLE_OBJECTS: SidebarObjectKind[] = ["TABLE"];
|
const TABLE_OBJECTS: SidebarObjectKind[] = ["TABLE"];
|
||||||
const TABLE_VIEW_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW"];
|
const TABLE_VIEW_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW"];
|
||||||
|
const TABLE_VIEW_PROCEDURE_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE"];
|
||||||
const TABLE_FUNCTION_OBJECTS: SidebarObjectKind[] = ["TABLE", "FUNCTION"];
|
const TABLE_FUNCTION_OBJECTS: SidebarObjectKind[] = ["TABLE", "FUNCTION"];
|
||||||
const ROUTINE_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FUNCTION"];
|
const ROUTINE_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FUNCTION"];
|
||||||
const POSTGRES_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "SEQUENCE"];
|
const POSTGRES_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "SEQUENCE"];
|
||||||
@@ -17,7 +18,8 @@ const ORACLE_OBJECTS: SidebarObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FUNC
|
|||||||
|
|
||||||
const TABLE_ONLY_TYPES = new Set<DatabaseType>(["influxdb"]);
|
const TABLE_ONLY_TYPES = new Set<DatabaseType>(["influxdb"]);
|
||||||
const TABLE_FUNCTION_TYPES = new Set<DatabaseType>(["manticoresearch"]);
|
const TABLE_FUNCTION_TYPES = new Set<DatabaseType>(["manticoresearch"]);
|
||||||
const TABLE_VIEW_ONLY_TYPES = new Set<DatabaseType>(["sqlite", "rqlite", "turso", "duckdb", "clickhouse", "doris", "starrocks", "databend", "hive", "trino", "cassandra", "bigquery", "kylin", "tdengine", "iotdb", "neo4j", "questdb"]);
|
const TABLE_VIEW_PROCEDURE_TYPES = new Set<DatabaseType>(["databend"]);
|
||||||
|
const TABLE_VIEW_ONLY_TYPES = new Set<DatabaseType>(["sqlite", "rqlite", "turso", "duckdb", "clickhouse", "doris", "starrocks", "hive", "trino", "cassandra", "bigquery", "kylin", "tdengine", "iotdb", "neo4j", "questdb"]);
|
||||||
|
|
||||||
const ORACLE_PACKAGE_TYPES = new Set<DatabaseType>(["oracle", "oceanbase-oracle"]);
|
const ORACLE_PACKAGE_TYPES = new Set<DatabaseType>(["oracle", "oceanbase-oracle"]);
|
||||||
const POSTGRES_SEQUENCE_TYPES = new Set<DatabaseType>(["postgres", "gaussdb", "kwdb", "opengauss"]);
|
const POSTGRES_SEQUENCE_TYPES = new Set<DatabaseType>(["postgres", "gaussdb", "kwdb", "opengauss"]);
|
||||||
@@ -36,6 +38,7 @@ export function sidebarObjectKindsForDatabase(dbType?: DatabaseType): SidebarObj
|
|||||||
if (ORACLE_PACKAGE_TYPES.has(dbType)) return [...ORACLE_OBJECTS];
|
if (ORACLE_PACKAGE_TYPES.has(dbType)) return [...ORACLE_OBJECTS];
|
||||||
if (TABLE_ONLY_TYPES.has(dbType)) return [...TABLE_OBJECTS];
|
if (TABLE_ONLY_TYPES.has(dbType)) return [...TABLE_OBJECTS];
|
||||||
if (TABLE_FUNCTION_TYPES.has(dbType)) return [...TABLE_FUNCTION_OBJECTS];
|
if (TABLE_FUNCTION_TYPES.has(dbType)) return [...TABLE_FUNCTION_OBJECTS];
|
||||||
|
if (TABLE_VIEW_PROCEDURE_TYPES.has(dbType)) return [...TABLE_VIEW_PROCEDURE_OBJECTS];
|
||||||
if (TABLE_VIEW_ONLY_TYPES.has(dbType)) return [...TABLE_VIEW_OBJECTS];
|
if (TABLE_VIEW_ONLY_TYPES.has(dbType)) return [...TABLE_VIEW_OBJECTS];
|
||||||
if (POSTGRES_SEQUENCE_TYPES.has(dbType)) return [...POSTGRES_OBJECTS];
|
if (POSTGRES_SEQUENCE_TYPES.has(dbType)) return [...POSTGRES_OBJECTS];
|
||||||
return [...ROUTINE_OBJECTS];
|
return [...ROUTINE_OBJECTS];
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ const NAVICAT_STYLE_TABLE_DATA_TYPES = new Set<DatabaseType>([
|
|||||||
"informix",
|
"informix",
|
||||||
"bigquery",
|
"bigquery",
|
||||||
"sundb",
|
"sundb",
|
||||||
|
"databend",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const DATABASE_CAPABILITY_OVERRIDES: Partial<Record<DatabaseType, Partial<DatabaseCapability>>> = {
|
const DATABASE_CAPABILITY_OVERRIDES: Partial<Record<DatabaseType, Partial<DatabaseCapability>>> = {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface RoutineParameterValue extends RoutineParameter {
|
|||||||
|
|
||||||
export function qualifiedRoutineName(options: BuildRoutineExecutionSqlOptions): string {
|
export function qualifiedRoutineName(options: BuildRoutineExecutionSqlOptions): string {
|
||||||
const { databaseType, schema, routineName } = options;
|
const { databaseType, schema, routineName } = options;
|
||||||
|
if (databaseType === "databend") return routineName;
|
||||||
if (isSchemaAware(databaseType) && schema) {
|
if (isSchemaAware(databaseType) && schema) {
|
||||||
return `${quoteTableIdentifier(databaseType, schema)}.${quoteTableIdentifier(databaseType, routineName)}`;
|
return `${quoteTableIdentifier(databaseType, schema)}.${quoteTableIdentifier(databaseType, routineName)}`;
|
||||||
}
|
}
|
||||||
@@ -49,6 +50,9 @@ export function buildProcedureExecutionSqlFromValues(options: BuildRoutineExecut
|
|||||||
if (options.databaseType === "oracle" || options.databaseType === "dameng" || options.databaseType === "oceanbase-oracle") {
|
if (options.databaseType === "oracle" || options.databaseType === "dameng" || options.databaseType === "oceanbase-oracle") {
|
||||||
return `BEGIN\n ${routine}(${values.map((parameter) => routineArgumentSql(options.databaseType, parameter, useNamedArguments)).join(", ")});\nEND;`;
|
return `BEGIN\n ${routine}(${values.map((parameter) => routineArgumentSql(options.databaseType, parameter, useNamedArguments)).join(", ")});\nEND;`;
|
||||||
}
|
}
|
||||||
|
if (options.databaseType === "databend") {
|
||||||
|
return `CALL PROCEDURE ${routine}(${values.map((parameter) => routineArgumentSql(options.databaseType, parameter, useNamedArguments)).join(", ")});`;
|
||||||
|
}
|
||||||
return `CALL ${routine}(${values.map((parameter) => routineArgumentSql(options.databaseType, parameter, useNamedArguments)).join(", ")});`;
|
return `CALL ${routine}(${values.map((parameter) => routineArgumentSql(options.databaseType, parameter, useNamedArguments)).join(", ")});`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ export async function loadRoutineParameters(options: LoadRoutineParametersOption
|
|||||||
maxRows: 200,
|
maxRows: 200,
|
||||||
pageSize: 200,
|
pageSize: 200,
|
||||||
});
|
});
|
||||||
return routineParametersFromResult(result);
|
return routineParametersFromResult(result, options.databaseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function supportsRoutineParameterMetadata(databaseType?: DatabaseType): boolean {
|
export function supportsRoutineParameterMetadata(databaseType?: DatabaseType): boolean {
|
||||||
return databaseType === "postgres" || databaseType === "mysql" || databaseType === "doris" || databaseType === "starrocks" || databaseType === "sqlserver" || databaseType === "oracle" || databaseType === "dameng" || databaseType === "oceanbase-oracle";
|
return databaseType === "postgres" || databaseType === "mysql" || databaseType === "doris" || databaseType === "starrocks" || databaseType === "sqlserver" || databaseType === "oracle" || databaseType === "dameng" || databaseType === "oceanbase-oracle" || databaseType === "databend";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function routineParametersQuery(options: Pick<LoadRoutineParametersOptions, "database" | "databaseType" | "schema" | "routineName">): string | null {
|
export function routineParametersQuery(options: Pick<LoadRoutineParametersOptions, "database" | "databaseType" | "schema" | "routineName">): string | null {
|
||||||
@@ -79,6 +79,14 @@ WHERE SPECIFIC_SCHEMA = ${schema}
|
|||||||
AND SPECIFIC_NAME = ${name}
|
AND SPECIFIC_NAME = ${name}
|
||||||
AND ORDINAL_POSITION > 0
|
AND ORDINAL_POSITION > 0
|
||||||
ORDER BY ORDINAL_POSITION;`.trim();
|
ORDER BY ORDINAL_POSITION;`.trim();
|
||||||
|
}
|
||||||
|
if (options.databaseType === "databend") {
|
||||||
|
return `
|
||||||
|
SELECT arguments
|
||||||
|
FROM system.procedures
|
||||||
|
WHERE name = ${name}
|
||||||
|
ORDER BY procedure_id
|
||||||
|
LIMIT 1;`.trim();
|
||||||
}
|
}
|
||||||
if (options.databaseType === "sqlserver") {
|
if (options.databaseType === "sqlserver") {
|
||||||
return `
|
return `
|
||||||
@@ -113,7 +121,8 @@ ORDER BY SEQUENCE;`.trim();
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function routineParametersFromResult(result: QueryResult): RoutineParameter[] {
|
export function routineParametersFromResult(result: QueryResult, databaseType?: DatabaseType): RoutineParameter[] {
|
||||||
|
if (databaseType === "databend") return databendRoutineParametersFromResult(result);
|
||||||
return result.rows
|
return result.rows
|
||||||
.map((row, index) => ({
|
.map((row, index) => ({
|
||||||
name: String(row[0] || `arg${index + 1}`),
|
name: String(row[0] || `arg${index + 1}`),
|
||||||
@@ -125,6 +134,54 @@ export function routineParametersFromResult(result: QueryResult): RoutineParamet
|
|||||||
.filter((parameter) => parameter.mode !== "RETURN");
|
.filter((parameter) => parameter.mode !== "RETURN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function databendRoutineParametersFromResult(result: QueryResult): RoutineParameter[] {
|
||||||
|
const argumentsIndex = result.columns.findIndex((column) => column.toLowerCase() === "arguments");
|
||||||
|
const signature = String(result.rows[0]?.[argumentsIndex >= 0 ? argumentsIndex : 0] || "");
|
||||||
|
const inputTypes = databendInputTypesFromArguments(signature);
|
||||||
|
return inputTypes.map((dataType, index) => ({
|
||||||
|
name: `arg${index + 1}`,
|
||||||
|
dataType,
|
||||||
|
mode: "IN",
|
||||||
|
ordinal: index + 1,
|
||||||
|
hasDefault: false,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function databendInputTypesFromArguments(signature: string): string[] {
|
||||||
|
const openIndex = signature.indexOf("(");
|
||||||
|
if (openIndex < 0) return [];
|
||||||
|
let depth = 0;
|
||||||
|
for (let index = openIndex; index < signature.length; index += 1) {
|
||||||
|
const char = signature[index];
|
||||||
|
if (char === "(") depth += 1;
|
||||||
|
if (char === ")") {
|
||||||
|
depth -= 1;
|
||||||
|
if (depth === 0) {
|
||||||
|
return splitTopLevelComma(signature.slice(openIndex + 1, index)).filter(Boolean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function splitTopLevelComma(value: string): string[] {
|
||||||
|
const parts: string[] = [];
|
||||||
|
let current = "";
|
||||||
|
let depth = 0;
|
||||||
|
for (const char of value) {
|
||||||
|
if (char === "(") depth += 1;
|
||||||
|
if (char === ")") depth = Math.max(0, depth - 1);
|
||||||
|
if (char === "," && depth === 0) {
|
||||||
|
parts.push(current.trim());
|
||||||
|
current = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
current += char;
|
||||||
|
}
|
||||||
|
if (current.trim()) parts.push(current.trim());
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeParameterMode(value: unknown): RoutineParameterMode {
|
function normalizeParameterMode(value: unknown): RoutineParameterMode {
|
||||||
const mode = String(value || "IN")
|
const mode = String(value || "IN")
|
||||||
.toUpperCase()
|
.toUpperCase()
|
||||||
|
|||||||
@@ -604,7 +604,7 @@
|
|||||||
"objectSource": false,
|
"objectSource": false,
|
||||||
"schemaSearch": false,
|
"schemaSearch": false,
|
||||||
"diagram": false,
|
"diagram": false,
|
||||||
"tableDataEdit": false,
|
"tableDataEdit": true,
|
||||||
"tableStructureEdit": true,
|
"tableStructureEdit": true,
|
||||||
"tableImport": false,
|
"tableImport": false,
|
||||||
"dataTransfer": false,
|
"dataTransfer": false,
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ impl AppState {
|
|||||||
.await?;
|
.await?;
|
||||||
PoolKind::Mysql(pool, mode)
|
PoolKind::Mysql(pool, mode)
|
||||||
}
|
}
|
||||||
DatabaseType::Doris | DatabaseType::StarRocks | DatabaseType::ManticoreSearch | DatabaseType::Databend => {
|
DatabaseType::Doris | DatabaseType::StarRocks | DatabaseType::ManticoreSearch => {
|
||||||
let pool = if database.is_none() {
|
let pool = if database.is_none() {
|
||||||
connect_bare_metadata_pool(&db_config, &host, port, connect_timeout, mysql_pool_max_connections)
|
connect_bare_metadata_pool(&db_config, &host, port, connect_timeout, mysql_pool_max_connections)
|
||||||
.await?
|
.await?
|
||||||
@@ -538,6 +538,7 @@ impl AppState {
|
|||||||
| DatabaseType::Highgo
|
| DatabaseType::Highgo
|
||||||
| DatabaseType::Vastbase
|
| DatabaseType::Vastbase
|
||||||
| DatabaseType::Goldendb
|
| DatabaseType::Goldendb
|
||||||
|
| DatabaseType::Databend
|
||||||
| DatabaseType::Yashandb
|
| DatabaseType::Yashandb
|
||||||
| DatabaseType::Databricks
|
| DatabaseType::Databricks
|
||||||
| DatabaseType::SapHana
|
| DatabaseType::SapHana
|
||||||
@@ -1131,6 +1132,11 @@ fn shares_database_pool_with_connection(db_type: &DatabaseType) -> bool {
|
|||||||
matches!(db_type, DatabaseType::Oracle)
|
matches!(db_type, DatabaseType::Oracle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn uses_bare_mysql_pool(db_type: &DatabaseType) -> bool {
|
||||||
|
matches!(db_type, DatabaseType::Doris | DatabaseType::StarRocks | DatabaseType::ManticoreSearch)
|
||||||
|
}
|
||||||
|
|
||||||
fn default_plugin_dir() -> PathBuf {
|
fn default_plugin_dir() -> PathBuf {
|
||||||
default_dbx_dir().join("plugins")
|
default_dbx_dir().join("plugins")
|
||||||
}
|
}
|
||||||
@@ -1308,14 +1314,15 @@ async fn detect_ob_oracle_mode(config: &ConnectionConfig, pool: &db::mysql::MySq
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
connection_url_for_endpoint, database_connection_config, metadata_connection_config,
|
connection_url_for_endpoint, database_connection_config, metadata_connection_config,
|
||||||
mysql_metadata_fallback_url, redacted_connection_url_for_endpoint, uses_tcp_probe, validate_h2_database_path,
|
mysql_metadata_fallback_url, redacted_connection_url_for_endpoint, uses_bare_mysql_pool, uses_tcp_probe,
|
||||||
AppState, PoolKind,
|
validate_h2_database_path, AppState, PoolKind,
|
||||||
};
|
};
|
||||||
use crate::agent_connection::{
|
use crate::agent_connection::{
|
||||||
agent_connect_params, mongo_legacy_error_with_auth_hint, mongo_uses_legacy_driver,
|
agent_connect_params, mongo_legacy_error_with_auth_hint, mongo_uses_legacy_driver,
|
||||||
oracle_alternate_connect_config, should_retry_mongo_with_legacy_driver, should_retry_oracle_with_10g_driver,
|
oracle_alternate_connect_config, should_retry_mongo_with_legacy_driver, should_retry_oracle_with_10g_driver,
|
||||||
};
|
};
|
||||||
use crate::agent_manager::{AgentState, JavaRuntimeConfig, JavaRuntimeMode, DEFAULT_JRE_KEY};
|
use crate::agent_manager::{AgentState, JavaRuntimeConfig, JavaRuntimeMode, DEFAULT_JRE_KEY};
|
||||||
|
use crate::database_capabilities;
|
||||||
use crate::db;
|
use crate::db;
|
||||||
use crate::models::connection::{
|
use crate::models::connection::{
|
||||||
default_connect_timeout_secs, default_redis_key_separator, ConnectionConfig, DatabaseType, ProxyTunnelConfig,
|
default_connect_timeout_secs, default_redis_key_separator, ConnectionConfig, DatabaseType, ProxyTunnelConfig,
|
||||||
@@ -1387,6 +1394,15 @@ mod tests {
|
|||||||
assert_eq!(params["url_params"], "INFORMIXSERVER=informix;CLIENT_LOCALE=en_US.utf8");
|
assert_eq!(params["url_params"], "INFORMIXSERVER=informix;CLIENT_LOCALE=en_US.utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn databend_uses_agent_pool_not_bare_mysql_pool() {
|
||||||
|
assert!(uses_bare_mysql_pool(&DatabaseType::Doris));
|
||||||
|
assert!(uses_bare_mysql_pool(&DatabaseType::StarRocks));
|
||||||
|
assert!(uses_bare_mysql_pool(&DatabaseType::ManticoreSearch));
|
||||||
|
assert!(!uses_bare_mysql_pool(&DatabaseType::Databend));
|
||||||
|
assert!(database_capabilities::is_agent_type(&DatabaseType::Databend));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn validates_h2_database_base_path_when_mv_db_file_exists() {
|
fn validates_h2_database_base_path_when_mv_db_file_exists() {
|
||||||
let dir = std::env::temp_dir().join(format!("dbx-h2-test-{}", uuid::Uuid::new_v4()));
|
let dir = std::env::temp_dir().join(format!("dbx-h2-test-{}", uuid::Uuid::new_v4()));
|
||||||
|
|||||||
@@ -1584,6 +1584,34 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prepares_databend_save_statements() {
|
||||||
|
let result = prepare_data_grid_save(DataGridSaveStatementOptions {
|
||||||
|
database_type: Some(DatabaseType::Databend),
|
||||||
|
table_meta: DataGridTableMeta {
|
||||||
|
schema: Some("default".to_string()),
|
||||||
|
table_name: "people".to_string(),
|
||||||
|
primary_keys: vec!["id".to_string()],
|
||||||
|
columns: Some(vec![column("id", "int", false, None), column("name", "string", true, None)]),
|
||||||
|
},
|
||||||
|
columns: vec!["id".to_string(), "name".to_string()],
|
||||||
|
source_columns: None,
|
||||||
|
rows: vec![vec![json!(1), json!("Ada")]],
|
||||||
|
dirty_rows: vec![(0, vec![(1, json!("Linus"))])],
|
||||||
|
deleted_rows: vec![0],
|
||||||
|
new_rows: vec![vec![json!(2), json!("Grace")]],
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
result.statements,
|
||||||
|
vec![
|
||||||
|
"UPDATE `default`.`people` SET `name` = 'Linus' WHERE `id` = 1;",
|
||||||
|
"DELETE FROM `default`.`people` WHERE `id` = 1;",
|
||||||
|
"INSERT INTO `default`.`people` (`id`, `name`) VALUES (2, 'Grace');",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn skips_expression_only_source_columns() {
|
fn skips_expression_only_source_columns() {
|
||||||
let result = prepare_data_grid_save(DataGridSaveStatementOptions {
|
let result = prepare_data_grid_save(DataGridSaveStatementOptions {
|
||||||
|
|||||||
@@ -201,6 +201,14 @@ test("uses Navicat-style table editing defaults for updateable SQL table engines
|
|||||||
requiresTransactionalTableForExistingRows: false,
|
requiresTransactionalTableForExistingRows: false,
|
||||||
transaction: true,
|
transaction: true,
|
||||||
});
|
});
|
||||||
|
assert.deepEqual(getDatabaseCapability("databend").tableData, {
|
||||||
|
insert: true,
|
||||||
|
updateRequiresPrimaryKey: false,
|
||||||
|
deleteRequiresPrimaryKey: false,
|
||||||
|
keylessRowPredicate: true,
|
||||||
|
requiresTransactionalTableForExistingRows: false,
|
||||||
|
transaction: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("keeps conservative table editing defaults for unknown database types", () => {
|
test("keeps conservative table editing defaults for unknown database types", () => {
|
||||||
@@ -318,7 +326,7 @@ test("object browser entry follows database tree shape", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("sidebar object capability registry describes object groups by database type", () => {
|
test("sidebar object capability registry describes object groups by database type", () => {
|
||||||
assert.deepEqual(sidebarObjectKindsForDatabase("databend"), ["TABLE", "VIEW"]);
|
assert.deepEqual(sidebarObjectKindsForDatabase("databend"), ["TABLE", "VIEW", "PROCEDURE"]);
|
||||||
assert.deepEqual(sidebarObjectKindsForDatabase("manticoresearch"), ["TABLE", "FUNCTION"]);
|
assert.deepEqual(sidebarObjectKindsForDatabase("manticoresearch"), ["TABLE", "FUNCTION"]);
|
||||||
assert.deepEqual(sidebarObjectKindsForDatabase("postgres"), ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "SEQUENCE"]);
|
assert.deepEqual(sidebarObjectKindsForDatabase("postgres"), ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "SEQUENCE"]);
|
||||||
assert.deepEqual(sidebarObjectKindsForDatabase("oracle"), ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE_BODY"]);
|
assert.deepEqual(sidebarObjectKindsForDatabase("oracle"), ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE_BODY"]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ test("builds procedure execution templates for common dialect families", () => {
|
|||||||
assert.equal(buildProcedureExecutionSql({ databaseType: "mysql", schema: "app", routineName: "refresh_stats" }), "CALL `refresh_stats`();");
|
assert.equal(buildProcedureExecutionSql({ databaseType: "mysql", schema: "app", routineName: "refresh_stats" }), "CALL `refresh_stats`();");
|
||||||
assert.equal(buildProcedureExecutionSql({ databaseType: "sqlserver", schema: "dbo", routineName: "refresh_stats" }), "EXEC [dbo].[refresh_stats];");
|
assert.equal(buildProcedureExecutionSql({ databaseType: "sqlserver", schema: "dbo", routineName: "refresh_stats" }), "EXEC [dbo].[refresh_stats];");
|
||||||
assert.equal(buildProcedureExecutionSql({ databaseType: "dameng", schema: "SYSDBA", routineName: "refresh_stats" }), 'BEGIN\n "SYSDBA"."refresh_stats"();\nEND;');
|
assert.equal(buildProcedureExecutionSql({ databaseType: "dameng", schema: "SYSDBA", routineName: "refresh_stats" }), 'BEGIN\n "SYSDBA"."refresh_stats"();\nEND;');
|
||||||
|
assert.equal(buildProcedureExecutionSql({ databaseType: "databend", schema: "default", routineName: "refresh_stats" }), "CALL PROCEDURE refresh_stats();");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("builds procedure execution templates from parameter values", () => {
|
test("builds procedure execution templates from parameter values", () => {
|
||||||
@@ -122,10 +123,28 @@ test("maps routine parameter query results into form metadata", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("maps Databend procedure signatures into positional input parameters", () => {
|
||||||
|
const parameters = routineParametersFromResult(
|
||||||
|
{
|
||||||
|
columns: ["arguments"],
|
||||||
|
rows: [["convert_weight(Decimal(10, 2), String) RETURN (Decimal(10, 2))"]],
|
||||||
|
affected_rows: 0,
|
||||||
|
execution_time_ms: 1,
|
||||||
|
},
|
||||||
|
"databend",
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(parameters, [
|
||||||
|
{ name: "arg1", dataType: "Decimal(10, 2)", mode: "IN", ordinal: 1, hasDefault: false },
|
||||||
|
{ name: "arg2", dataType: "String", mode: "IN", ordinal: 2, hasDefault: false },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
test("builds parameter metadata queries for supported dialects", () => {
|
test("builds parameter metadata queries for supported dialects", () => {
|
||||||
assert.match(routineParametersQuery({ database: "app", databaseType: "postgres", schema: "public", routineName: "demo" }) ?? "", /pg_proc/);
|
assert.match(routineParametersQuery({ database: "app", databaseType: "postgres", schema: "public", routineName: "demo" }) ?? "", /pg_proc/);
|
||||||
assert.match(routineParametersQuery({ database: "app", databaseType: "sqlserver", schema: "dbo", routineName: "demo" }) ?? "", /sys\.parameters/);
|
assert.match(routineParametersQuery({ database: "app", databaseType: "sqlserver", schema: "dbo", routineName: "demo" }) ?? "", /sys\.parameters/);
|
||||||
assert.match(routineParametersQuery({ database: "app", databaseType: "mysql", routineName: "demo" }) ?? "", /SPECIFIC_SCHEMA = 'app'/);
|
assert.match(routineParametersQuery({ database: "app", databaseType: "mysql", routineName: "demo" }) ?? "", /SPECIFIC_SCHEMA = 'app'/);
|
||||||
|
assert.match(routineParametersQuery({ database: "default", databaseType: "databend", schema: "default", routineName: "demo" }) ?? "", /system\.procedures/);
|
||||||
assert.match(routineParametersQuery({ database: "app", databaseType: "postgres", routineName: "demo" }) ?? "", /n\.nspname = 'public'/);
|
assert.match(routineParametersQuery({ database: "app", databaseType: "postgres", routineName: "demo" }) ?? "", /n\.nspname = 'public'/);
|
||||||
assert.equal(routineParametersQuery({ database: "app", databaseType: "sqlite", schema: "main", routineName: "demo" }), null);
|
assert.equal(routineParametersQuery({ database: "app", databaseType: "sqlite", schema: "main", routineName: "demo" }), null);
|
||||||
});
|
});
|
||||||
@@ -53,6 +53,7 @@ test("allows updateable SQL table data editing even without declared primary key
|
|||||||
assert.equal(isTableDataEditable("tdengine", []), true);
|
assert.equal(isTableDataEditable("tdengine", []), true);
|
||||||
assert.equal(isTableDataEditable("mysql", []), true);
|
assert.equal(isTableDataEditable("mysql", []), true);
|
||||||
assert.equal(isTableDataEditable("manticoresearch", []), true);
|
assert.equal(isTableDataEditable("manticoresearch", []), true);
|
||||||
|
assert.equal(isTableDataEditable("databend", []), true);
|
||||||
assert.equal(isTableDataEditable("postgres", []), true);
|
assert.equal(isTableDataEditable("postgres", []), true);
|
||||||
assert.equal(isTableDataEditable("postgres", ["id"]), true);
|
assert.equal(isTableDataEditable("postgres", ["id"]), true);
|
||||||
});
|
});
|
||||||
@@ -78,6 +79,7 @@ test("allows existing row edits according to database-specific key requirements"
|
|||||||
assert.equal(canEditExistingTableRows("trino", undefined, ["id"]), true);
|
assert.equal(canEditExistingTableRows("trino", undefined, ["id"]), true);
|
||||||
assert.equal(canEditExistingTableRows("mysql", undefined, []), true);
|
assert.equal(canEditExistingTableRows("mysql", undefined, []), true);
|
||||||
assert.equal(canEditExistingTableRows("manticoresearch", undefined, []), true);
|
assert.equal(canEditExistingTableRows("manticoresearch", undefined, []), true);
|
||||||
|
assert.equal(canEditExistingTableRows("databend", undefined, []), true);
|
||||||
assert.equal(canEditExistingTableRows("postgres", undefined, []), true);
|
assert.equal(canEditExistingTableRows("postgres", undefined, []), true);
|
||||||
assert.equal(canEditExistingTableRows("sqlite", undefined, []), true);
|
assert.equal(canEditExistingTableRows("sqlite", undefined, []), true);
|
||||||
assert.equal(canEditExistingTableRows("sqlite", undefined, ["id"]), true);
|
assert.equal(canEditExistingTableRows("sqlite", undefined, ["id"]), true);
|
||||||
|
|||||||
Reference in new issue
Block a user