feat(postgres): support editing table owners
This commit is contained in:
32 files changed
+556
-36
No files matched your search
@@ -186,6 +186,7 @@ export const listFunctions = forward("listFunctions");
|
||||
export const listSequences = forward("listSequences");
|
||||
export const listRules = forward("listRules");
|
||||
export const listOwners = forward("listOwners");
|
||||
export const getTableOwner = forward("getTableOwner");
|
||||
export const listExtensions = forward("listExtensions");
|
||||
export const listAvailableExtensions = forward("listAvailableExtensions");
|
||||
export const prepareSchemaDiff = forward("prepareSchemaDiff");
|
||||
@@ -252,6 +253,7 @@ export const buildEditableObjectSource = forward("buildEditableObjectSource");
|
||||
export const buildRoutineRenameObjectSourceStatements = forward("buildRoutineRenameObjectSourceStatements");
|
||||
export const buildViewDdlSql = forward("buildViewDdlSql");
|
||||
export const buildTableStructureChangeSql = forward("buildTableStructureChangeSql");
|
||||
export const buildTableOwnerChangeSql = forward("buildTableOwnerChangeSql");
|
||||
export const previewSqliteTableStructureChange = forward("previewSqliteTableStructureChange");
|
||||
export const applySqliteTableStructureChange = forward("applySqliteTableStructureChange");
|
||||
export const buildCreateTableSql = forward("buildCreateTableSql");
|
||||
|
||||
@@ -159,7 +159,7 @@ import type {
|
||||
HiveTablePropertiesSqlOptions,
|
||||
} from "@/lib/dataGrid/dataGridSql";
|
||||
import type { DataGridExtractRequest, DataGridExtractResult } from "@/lib/dataGrid/dataGridCopyExtractor";
|
||||
import type { BuildTableStructureChangeSqlOptions, BuildSingleColumnAlterSqlOptions, SqliteTableStructureChangePreview, TableStructureChangeSql } from "@/lib/table/tableStructureEditorSql";
|
||||
import type { BuildTableOwnerChangeSqlOptions, BuildTableStructureChangeSqlOptions, BuildSingleColumnAlterSqlOptions, SqliteTableStructureChangePreview, TableStructureChangeSql } from "@/lib/table/tableStructureEditorSql";
|
||||
import type { BuildTableSelectSqlOptions } from "@/lib/table/tableSelectSql";
|
||||
import type { DatabaseSearchSql, DatabaseSearchSqlOptions, SearchResultWhereOptions } from "@/lib/database/databaseSearch";
|
||||
import type { BuildEditableObjectSourceSqlInput, BuildRoutineRenameObjectSourceInput } from "@/lib/table/objectSourceEditor";
|
||||
@@ -969,6 +969,10 @@ export async function listOwners(connectionId: string, database: string, schema:
|
||||
return get(`/api/schema/owners?${qs({ connection_id: connectionId, database, schema })}`);
|
||||
}
|
||||
|
||||
export async function getTableOwner(connectionId: string, database: string, schema: string, table: string): Promise<string | null> {
|
||||
return get(`/api/schema/table-owner?${qs({ connection_id: connectionId, database, schema, table })}`);
|
||||
}
|
||||
|
||||
export async function listExtensions(connectionId: string, database: string, schema?: string): Promise<ExtensionInfo[]> {
|
||||
return get(`/api/schema/extensions?${qs({ connection_id: connectionId, database, schema })}`);
|
||||
}
|
||||
@@ -1425,6 +1429,10 @@ export async function buildTableStructureChangeSql(options: BuildTableStructureC
|
||||
return post("/api/query/build-table-structure-change-sql", { options });
|
||||
}
|
||||
|
||||
export async function buildTableOwnerChangeSql(options: BuildTableOwnerChangeSqlOptions): Promise<TableStructureChangeSql> {
|
||||
return post("/api/query/build-table-owner-change-sql", { options });
|
||||
}
|
||||
|
||||
export async function previewSqliteTableStructureChange(connectionId: string, database: string, options: BuildTableStructureChangeSqlOptions): Promise<SqliteTableStructureChangePreview> {
|
||||
return post("/api/query/preview-sqlite-table-structure-change", {
|
||||
connectionId,
|
||||
|
||||
@@ -83,7 +83,7 @@ import type {
|
||||
import type { DataGridExtractRequest, DataGridExtractResult } from "@/lib/dataGrid/dataGridCopyExtractor";
|
||||
import type { DataCompareFromTablesOptions, DataCompareFromTablesPreparation, DataCompareSyncPlan, DataCompareSyncPlanOptions, DataComparePreparation, DataComparePreparationOptions } from "@/lib/dataGrid/dataCompare";
|
||||
import type { SchemaDiffPreparation, SchemaDiffPreparationOptions, TableDiff, FunctionDiff, SequenceDiff, RuleDiff, OwnerDiff } from "@/lib/schema/schemaDiff";
|
||||
import type { BuildTableStructureChangeSqlOptions, BuildSingleColumnAlterSqlOptions, SqliteTableStructureChangePreview, TableStructureChangeSql } from "@/lib/table/tableStructureEditorSql";
|
||||
import type { BuildTableOwnerChangeSqlOptions, BuildTableStructureChangeSqlOptions, BuildSingleColumnAlterSqlOptions, SqliteTableStructureChangePreview, TableStructureChangeSql } from "@/lib/table/tableStructureEditorSql";
|
||||
import type { BuildTableSelectSqlOptions } from "@/lib/table/tableSelectSql";
|
||||
import type { DatabaseSearchSql, DatabaseSearchSqlOptions, SearchResultWhereOptions } from "@/lib/database/databaseSearch";
|
||||
import type { BuildEditableObjectSourceSqlInput, BuildRoutineRenameObjectSourceInput } from "@/lib/table/objectSourceEditor";
|
||||
@@ -1603,6 +1603,10 @@ export async function buildTableStructureChangeSql(options: BuildTableStructureC
|
||||
return invoke("build_table_structure_change_sql", { options });
|
||||
}
|
||||
|
||||
export async function buildTableOwnerChangeSql(options: BuildTableOwnerChangeSqlOptions): Promise<TableStructureChangeSql> {
|
||||
return invoke("build_table_owner_change_sql", { options });
|
||||
}
|
||||
|
||||
export async function previewSqliteTableStructureChange(connectionId: string, database: string, options: BuildTableStructureChangeSqlOptions): Promise<SqliteTableStructureChangePreview> {
|
||||
return invoke("preview_sqlite_table_structure_change", {
|
||||
connectionId,
|
||||
@@ -1876,6 +1880,10 @@ export async function listOwners(connectionId: string, database: string, schema:
|
||||
return invoke("list_owners", { connectionId, database, schema });
|
||||
}
|
||||
|
||||
export async function getTableOwner(connectionId: string, database: string, schema: string, table: string): Promise<string | null> {
|
||||
return invoke("get_table_owner", { connectionId, database, schema, table });
|
||||
}
|
||||
|
||||
export async function listExtensions(connectionId: string, database: string, schema?: string): Promise<ExtensionInfo[]> {
|
||||
return invoke("list_extensions", { connectionId, database, schema });
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@ describe("SearchableSelect layout", () => {
|
||||
expect(labelBoundaries).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("can preserve custom option whitespace for exact database identifiers", () => {
|
||||
expect(searchableSelectSource).toContain("trimCustom?: boolean");
|
||||
expect(searchableSelectSource).toContain("trimCustom: true");
|
||||
expect(searchableSelectSource).toContain("props.trimCustom ? searchText.value.trim() : searchText.value");
|
||||
});
|
||||
|
||||
it("truncates long data transfer connection labels without shrinking their icons", () => {
|
||||
const truncatedConnectionLabels = dataTransferDialogSource.match(/<span class="min-w-0 flex-1 truncate">\{\{ label \}\}<\/span>/g) ?? [];
|
||||
const fixedConnectionIcons = dataTransferDialogSource.match(/class="h-3\.5 w-3\.5 shrink-0"/g) ?? [];
|
||||
|
||||
@@ -49,7 +49,7 @@ async function deleteSchemaCachePrefixSafe(prefix: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export type ObjectMetadataFacet = "columns" | "indexes" | "foreign-keys" | "constraints" | "triggers" | "comment";
|
||||
export type ObjectMetadataFacet = "columns" | "indexes" | "foreign-keys" | "constraints" | "triggers" | "comment" | "owner";
|
||||
|
||||
function cacheSegment(value: string | undefined): string {
|
||||
return encodeURIComponent(value ?? "");
|
||||
|
||||
@@ -97,6 +97,14 @@ export interface TableStructureChangeSql {
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
export interface BuildTableOwnerChangeSqlOptions {
|
||||
databaseType?: DatabaseType;
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
owner: string;
|
||||
originalOwner: string;
|
||||
}
|
||||
|
||||
export interface SqliteTableStructureChangePreview extends TableStructureChangeSql {
|
||||
schemaRevision: string;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user