Update foreign table to distant table schema (#5508)
Closes #5069 back-end part And: - do not display schemaPendingUpdates status on remote server lists as this call will become too costly if there are dozens of servers - (refacto) create foreignTableService After this is merged we will be able to delete remoteTable's availableTables column
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
import { PostgresTableSchemaColumn } from 'src/engine/metadata-modules/remote-server/types/postgres-table-schema-column';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
|
||||
export const fetchTableColumns = async (
|
||||
workspaceDataSourceService: WorkspaceDataSourceService,
|
||||
workspaceId: string,
|
||||
tableName: string,
|
||||
): Promise<PostgresTableSchemaColumn[]> => {
|
||||
const schemaName = workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const res = await workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT column_name, data_type, udt_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = $1 AND table_name = $2`,
|
||||
[schemaName, tableName],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
return res.map((column) => ({
|
||||
columnName: column.column_name,
|
||||
dataType: column.data_type,
|
||||
udtName: column.udt_name,
|
||||
}));
|
||||
};
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
import camelCase from 'lodash.camelcase';
|
||||
|
||||
export const getForeignTableColumnName = (distantTableColumnName: string) => {
|
||||
return camelCase(distantTableColumnName);
|
||||
};
|
||||
Reference in New Issue
Block a user