mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 00:19:35 +00:00
fix(clickhouse): make table data fully read-only
Add readonly flag to TableDataCapability and check it in isTableDataEditable and canEditExistingTableRows to prevent cell editing for databases like ClickHouse that don't support row-level UPDATE/DELETE.
This commit is contained in:
@@ -9,6 +9,7 @@ export interface TableDataCapability {
|
||||
deleteRequiresPrimaryKey: boolean;
|
||||
requiresTransactionalTableForExistingRows: boolean;
|
||||
transaction: boolean;
|
||||
readonly?: boolean;
|
||||
}
|
||||
|
||||
export interface DatabaseCapability {
|
||||
@@ -73,6 +74,7 @@ const DATABASE_CAPABILITY_OVERRIDES: Partial<Record<DatabaseType, Partial<Databa
|
||||
deleteRequiresPrimaryKey: true,
|
||||
requiresTransactionalTableForExistingRows: false,
|
||||
transaction: false,
|
||||
readonly: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,9 @@ export function editablePrimaryKeys(databaseType: DatabaseType | undefined, colu
|
||||
}
|
||||
|
||||
export function isTableDataEditable(databaseType: DatabaseType | undefined, primaryKeys: string[]): boolean {
|
||||
if (getDatabaseCapability(databaseType).tableData.insert) return true;
|
||||
const cap = getDatabaseCapability(databaseType).tableData;
|
||||
if (cap.readonly) return false;
|
||||
if (cap.insert) return true;
|
||||
return primaryKeys.length > 0;
|
||||
}
|
||||
|
||||
@@ -27,6 +29,7 @@ export function canEditExistingTableRows(
|
||||
primaryKeys?: string[],
|
||||
): boolean {
|
||||
const tableData = getDatabaseCapability(databaseType).tableData;
|
||||
if (tableData.readonly) return false;
|
||||
if (tableData.requiresTransactionalTableForExistingRows && hiveTableTransactional !== true) return false;
|
||||
if (tableData.updateRequiresPrimaryKey && primaryKeys && primaryKeys.length === 0) return false;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user