diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index a254f30b60..bfba57f392 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -1566,7 +1566,7 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
- {{ item.name }}
+ {{ item.displayName }}
{{ t("objects.partitions", { count: item.partitionCount }) }}
diff --git a/apps/desktop/src/lib/objectBrowserRows.ts b/apps/desktop/src/lib/objectBrowserRows.ts
index c5fa39a51b..7606cdd4cd 100644
--- a/apps/desktop/src/lib/objectBrowserRows.ts
+++ b/apps/desktop/src/lib/objectBrowserRows.ts
@@ -5,8 +5,10 @@ import { parseSlashDelimitedRegexQuery } from "@/lib/searchPattern";
export type ObjectBrowserRow = {
id: string;
name: string;
+ displayName: string;
schema?: string;
type: "TABLE" | "VIEW" | "MATERIALIZED_VIEW" | "PROCEDURE" | "FUNCTION" | "SEQUENCE" | "PACKAGE" | "PACKAGE_BODY";
+ signature?: string | null;
comment?: string | null;
created_at?: string | null;
updated_at?: string | null;
@@ -42,15 +44,20 @@ export function buildObjectBrowserRows(options: { objects: ObjectInfo[]; databas
const objectSchema = object.schema ? normalizeDatabaseObjectName(object.schema) : undefined;
const schema = objectSchema || (options.needsSchema ? options.fallbackSchema : undefined);
const type = normalizeObjectBrowserType(object.object_type);
- const baseId = `${schema || options.fallbackSchema || options.database}:${name}:${type}`;
+ const signature = routineSignatureForDisplay(type, object.signature);
+ const displayName = signature === undefined ? name : `${name}(${signature})`;
+ const signatureIdPart = signature === undefined ? "" : `:${signature}`;
+ const baseId = `${schema || options.fallbackSchema || options.database}:${name}:${type}${signatureIdPart}`;
const index = seen.get(baseId) ?? 0;
seen.set(baseId, index + 1);
return [
{
id: `${baseId}:${index}`,
name,
+ displayName,
schema,
type,
+ signature,
comment: object.comment,
created_at: object.created_at,
updated_at: object.updated_at,
@@ -64,6 +71,12 @@ export function buildObjectBrowserRows(options: { objects: ObjectInfo[]; databas
return rows;
}
+function routineSignatureForDisplay(type: ObjectBrowserRow["type"], signature: string | null | undefined): string | undefined {
+ if (type !== "PROCEDURE" && type !== "FUNCTION") return undefined;
+ if (signature == null) return undefined;
+ return signature.trim();
+}
+
function markPartitionRows(rows: ObjectBrowserRow[], fallbackSchema: string) {
const tableByKey = new Map();
for (const row of rows) {
@@ -102,18 +115,18 @@ export function filterObjectBrowserRows(rows: ObjectBrowserRow[], query: string)
if (!q) return rows;
const regex = parseSlashDelimitedRegexQuery(query.trim());
if (regex) {
- return rows.filter((row) => [row.name, row.type, row.comment].filter(Boolean).some((value) => regex.test(String(value))));
+ return rows.filter((row) => [row.displayName, row.name, row.type, row.comment].filter(Boolean).some((value) => regex.test(String(value))));
}
- return rows.filter((row) => [row.name, row.type, row.comment].filter(Boolean).some((value) => String(value).toLowerCase().includes(q)));
+ return rows.filter((row) => [row.displayName, row.name, row.type, row.comment].filter(Boolean).some((value) => String(value).toLowerCase().includes(q)));
}
export function sortObjectBrowserRows(rows: ObjectBrowserRow[], key: ObjectBrowserSortKey, direction: ObjectBrowserSortDirection): ObjectBrowserRow[] {
const multiplier = direction === "asc" ? 1 : -1;
- const compareNames = createDatabaseObjectNameComparator(rows.map((row) => row.name));
+ const compareNames = createDatabaseObjectNameComparator(rows.map((row) => row.displayName));
return [...rows].sort((left, right) => {
- const compared = key === "name" ? compareNames(left.name, right.name) : compareObjectBrowserValue(left[key], right[key], key, direction);
+ const compared = key === "name" ? compareNames(left.displayName, right.displayName) : compareObjectBrowserValue(left[key], right[key], key, direction);
if (compared !== 0) return compared * multiplier;
- return compareNames(left.name, right.name);
+ return compareNames(left.displayName, right.displayName);
});
}
diff --git a/apps/desktop/src/types/database.ts b/apps/desktop/src/types/database.ts
index 59e2f2f8ea..d47910af6e 100644
--- a/apps/desktop/src/types/database.ts
+++ b/apps/desktop/src/types/database.ts
@@ -281,6 +281,7 @@ export interface ObjectInfo {
name: string;
object_type: DatabaseObjectType | string;
schema?: string | null;
+ signature?: string | null;
comment?: string | null;
created_at?: string | null;
updated_at?: string | null;
diff --git a/crates/dbx-core/src/db/manticoresearch.rs b/crates/dbx-core/src/db/manticoresearch.rs
index 50303bcff8..3e5abad495 100644
--- a/crates/dbx-core/src/db/manticoresearch.rs
+++ b/crates/dbx-core/src/db/manticoresearch.rs
@@ -40,6 +40,7 @@ pub async fn list_objects(pool: &MySqlPool, database: &str) -> Result ObjectInfo {
name: get_str_by_name(row, "object_name"),
object_type: get_str_by_name(row, "object_type"),
schema: Some(database.to_string()),
+ signature: None,
comment: get_opt_str(row, "object_comment")
.map(|s| fix_potential_double_encoding(&s))
.filter(|s| !s.is_empty()),
@@ -1691,6 +1692,7 @@ pub async fn list_table_objects_show(pool: &MySqlPool, database: &str) -> Result
name: table.name,
object_type: if table.table_type.eq_ignore_ascii_case("VIEW") { "VIEW" } else { "TABLE" }.to_string(),
schema: Some(database.to_string()),
+ signature: None,
comment: table.comment,
created_at: meta.and_then(|meta| meta.created_at.clone()),
updated_at: meta.and_then(|meta| meta.updated_at.clone()),
diff --git a/crates/dbx-core/src/db/ob_oracle.rs b/crates/dbx-core/src/db/ob_oracle.rs
index 52fab42195..c62260b059 100644
--- a/crates/dbx-core/src/db/ob_oracle.rs
+++ b/crates/dbx-core/src/db/ob_oracle.rs
@@ -104,6 +104,7 @@ pub async fn list_objects(pool: &mysql_async::Pool, schema: &str) -> Result &'static str {
) AS updated_at, \
CASE WHEN pc.relkind = 'p' THEN pn.nspname ELSE NULL END AS parent_schema, \
CASE WHEN pc.relkind = 'p' THEN pc.relname ELSE NULL END AS parent_name, \
+ NULL::text AS signature, \
CASE c.relkind WHEN 'v' THEN 1 WHEN 'm' THEN 1 WHEN 'S' THEN 4 ELSE 0 END AS sort_order \
FROM pg_catalog.pg_class c \
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \
@@ -1555,6 +1556,7 @@ fn list_object_relations_sql(include_timestamps: bool) -> &'static str {
NULL::text AS updated_at, \
CASE WHEN pc.relkind = 'p' THEN pn.nspname ELSE NULL END AS parent_schema, \
CASE WHEN pc.relkind = 'p' THEN pc.relname ELSE NULL END AS parent_name, \
+ NULL::text AS signature, \
CASE c.relkind WHEN 'v' THEN 1 WHEN 'm' THEN 1 WHEN 'S' THEN 4 ELSE 0 END AS sort_order \
FROM pg_catalog.pg_class c \
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \
@@ -1575,6 +1577,7 @@ fn list_object_routines_sql(include_timestamps: bool, has_proc_prokind: bool) ->
THEN pg_xact_commit_timestamp(p.xmin)::text END AS updated_at, \
NULL::text AS parent_schema, \
NULL::text AS parent_name, \
+ pg_get_function_arguments(p.oid) AS signature, \
CASE p.prokind WHEN 'p' THEN 2 ELSE 3 END AS sort_order \
FROM pg_catalog.pg_proc p \
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace \
@@ -1588,6 +1591,7 @@ fn list_object_routines_sql(include_timestamps: bool, has_proc_prokind: bool) ->
NULL::text AS updated_at, \
NULL::text AS parent_schema, \
NULL::text AS parent_name, \
+ pg_get_function_arguments(p.oid) AS signature, \
CASE p.prokind WHEN 'p' THEN 2 ELSE 3 END AS sort_order \
FROM pg_catalog.pg_proc p \
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace \
@@ -1603,6 +1607,7 @@ fn list_object_routines_sql(include_timestamps: bool, has_proc_prokind: bool) ->
THEN pg_xact_commit_timestamp(p.xmin)::text END AS updated_at, \
NULL::text AS parent_schema, \
NULL::text AS parent_name, \
+ pg_get_function_arguments(p.oid) AS signature, \
3 AS sort_order \
FROM pg_catalog.pg_proc p \
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace \
@@ -1616,6 +1621,7 @@ fn list_object_routines_sql(include_timestamps: bool, has_proc_prokind: bool) ->
NULL::text AS updated_at, \
NULL::text AS parent_schema, \
NULL::text AS parent_name, \
+ pg_get_function_arguments(p.oid) AS signature, \
3 AS sort_order \
FROM pg_catalog.pg_proc p \
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace \
@@ -1671,6 +1677,7 @@ pub async fn list_objects(pool: &Pool, schema: &str) -> Result,
updated_at: row.try_get::<_, Option>(4).ok().flatten().filter(|s| !s.is_empty()),
parent_schema: row.try_get::<_, Option>(5).ok().flatten().filter(|s| !s.is_empty()),
parent_name: row.try_get::<_, Option>(6).ok().flatten().filter(|s| !s.is_empty()),
+ signature: row.try_get::<_, Option>(7).ok().flatten(),
})
.collect())
}
@@ -3218,6 +3225,8 @@ mod tests {
assert!(sql.contains("pg_catalog.pg_inherits"));
assert!(sql.contains("parent_schema"));
assert!(sql.contains("parent_name"));
+ assert!(sql.contains("NULL::text AS signature"));
+ assert!(sql.contains("pg_get_function_arguments(p.oid) AS signature"));
assert!(sql.contains("pc.relkind = 'p'"));
assert!(sql.contains("pg_stat_file"));
assert!(sql.contains("pg_xact_commit_timestamp"));
@@ -3255,6 +3264,7 @@ mod tests {
assert!(!sql.contains("p.prokind"));
assert!(sql.contains("NOT p.proisagg"));
assert!(sql.contains("NOT p.proiswindow"));
+ assert!(sql.contains("pg_get_function_arguments(p.oid) AS signature"));
assert!(sql.contains("'FUNCTION' AS object_type"));
assert!(!sql.contains("'PROCEDURE'"));
}
diff --git a/crates/dbx-core/src/db/questdb.rs b/crates/dbx-core/src/db/questdb.rs
index a64314a6b0..482484a3ca 100644
--- a/crates/dbx-core/src/db/questdb.rs
+++ b/crates/dbx-core/src/db/questdb.rs
@@ -12,6 +12,7 @@ pub async fn list_objects(pool: &Pool, schema: &str) -> Result,
name: t.name.clone(),
object_type: t.table_type.clone(),
schema: None,
+ signature: None,
comment: t.comment.clone(),
created_at: None,
updated_at: None,
diff --git a/crates/dbx-core/src/db/sqlserver.rs b/crates/dbx-core/src/db/sqlserver.rs
index 262728d821..dc218d3a39 100644
--- a/crates/dbx-core/src/db/sqlserver.rs
+++ b/crates/dbx-core/src/db/sqlserver.rs
@@ -1201,6 +1201,7 @@ pub async fn list_objects(client: &mut SqlServerClient, schema: &str) -> Result<
name: row.get::<&str, _>(0).unwrap_or("").to_string(),
object_type: row.get::<&str, _>(1).unwrap_or("TABLE").to_string(),
schema: Some(schema.to_string()),
+ signature: None,
comment: row.get::<&str, _>(4).filter(|s: &&str| !s.is_empty()).map(|s: &str| s.to_string()),
created_at: row.get::(2).map(|value| value.to_string()),
updated_at: row.get::(3).map(|value| value.to_string()),
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index a557a23cf8..5efd77aaab 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -1240,6 +1240,7 @@ async fn external_driver_presto_like_objects(
name: table.name,
object_type: table.table_type,
schema: Some(schema.to_string()),
+ signature: None,
comment: table.comment,
created_at: None,
updated_at: None,
@@ -2123,6 +2124,7 @@ async fn list_objects_once(
name: table.name,
object_type: table.table_type,
schema: None,
+ signature: None,
comment: table.comment,
created_at: None,
updated_at: None,
@@ -2226,6 +2228,7 @@ async fn list_objects_once(
name: table.name,
object_type: table.table_type,
schema: if schema.is_empty() { None } else { Some(schema.to_string()) },
+ signature: None,
comment: table.comment,
created_at: None,
updated_at: None,
@@ -3409,6 +3412,7 @@ async fn oracle_agent_list_objects(
name,
object_type,
schema,
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
diff --git a/crates/dbx-core/src/schema/normalization.rs b/crates/dbx-core/src/schema/normalization.rs
index 9041dc3f3f..878443ff3a 100644
--- a/crates/dbx-core/src/schema/normalization.rs
+++ b/crates/dbx-core/src/schema/normalization.rs
@@ -229,6 +229,7 @@ mod tests {
name: "orders".to_string(),
object_type: "BASE TABLE".to_string(),
schema: None,
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
@@ -239,6 +240,7 @@ mod tests {
name: "active_orders".to_string(),
object_type: "MATERIALIZED_VIEW".to_string(),
schema: None,
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
@@ -249,6 +251,7 @@ mod tests {
name: "payroll".to_string(),
object_type: "PACKAGE BODY".to_string(),
schema: None,
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
@@ -299,6 +302,7 @@ mod tests {
name: "ORDERS".to_string(),
object_type: "TABLE".to_string(),
schema: Some("HR".to_string()),
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
@@ -309,6 +313,7 @@ mod tests {
name: "bin$deleted".to_string(),
object_type: "TABLE".to_string(),
schema: Some("HR".to_string()),
+ signature: None,
comment: None,
created_at: None,
updated_at: None,
diff --git a/crates/dbx-core/src/types.rs b/crates/dbx-core/src/types.rs
index 030dce0738..63220e9a72 100644
--- a/crates/dbx-core/src/types.rs
+++ b/crates/dbx-core/src/types.rs
@@ -33,6 +33,8 @@ pub struct ObjectInfo {
pub name: String,
pub object_type: String,
pub schema: Option,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub signature: Option,
pub comment: Option,
pub created_at: Option,
pub updated_at: Option,
diff --git a/packages/app-tests/objectBrowserRows.test.ts b/packages/app-tests/objectBrowserRows.test.ts
index edd9956bb6..d0b99f1b36 100644
--- a/packages/app-tests/objectBrowserRows.test.ts
+++ b/packages/app-tests/objectBrowserRows.test.ts
@@ -5,9 +5,9 @@ import { buildObjectBrowserRows, filterObjectBrowserRows, formatObjectBrowserByt
test("builds unique row ids for overloaded routines with the same visible name", () => {
const rows = buildObjectBrowserRows({
objects: [
- { name: "list_pipes", object_type: "FUNCTION", schema: "dbms_pipe" },
- { name: "list_pipes", object_type: "FUNCTION", schema: "dbms_pipe" },
- { name: "create_pipe", object_type: "FUNCTION", schema: "dbms_pipe" },
+ { name: "list_pipes", object_type: "FUNCTION", schema: "dbms_pipe", signature: "" },
+ { name: "list_pipes", object_type: "FUNCTION", schema: "dbms_pipe", signature: "name text" },
+ { name: "create_pipe", object_type: "FUNCTION", schema: "dbms_pipe", signature: "" },
],
database: "highgo",
fallbackSchema: "dbms_pipe",
@@ -16,7 +16,33 @@ test("builds unique row ids for overloaded routines with the same visible name",
assert.deepEqual(
rows.map((row) => row.id),
- ["dbms_pipe:list_pipes:FUNCTION:0", "dbms_pipe:list_pipes:FUNCTION:1", "dbms_pipe:create_pipe:FUNCTION:0"],
+ ["dbms_pipe:list_pipes:FUNCTION::0", "dbms_pipe:list_pipes:FUNCTION:name text:0", "dbms_pipe:create_pipe:FUNCTION::0"],
+ );
+ assert.deepEqual(
+ rows.map((row) => row.displayName),
+ ["list_pipes()", "list_pipes(name text)", "create_pipe()"],
+ );
+ assert.deepEqual(
+ rows.map((row) => row.name),
+ ["list_pipes", "list_pipes", "create_pipe"],
+ );
+});
+
+test("object browser search matches routine signatures", () => {
+ const rows = buildObjectBrowserRows({
+ objects: [
+ { name: "refresh_stats", object_type: "PROCEDURE", schema: "public", signature: "target_table text" },
+ { name: "refresh_stats", object_type: "PROCEDURE", schema: "public", signature: "" },
+ { name: "orders", object_type: "TABLE", schema: "public" },
+ ],
+ database: "app",
+ fallbackSchema: "public",
+ needsSchema: true,
+ });
+
+ assert.deepEqual(
+ filterObjectBrowserRows(rows, "target_table").map((row) => row.displayName),
+ ["refresh_stats(target_table text)"],
);
});