442f8dbe3c
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
26 lines
933 B
TypeScript
26 lines
933 B
TypeScript
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,
|
|
);
|
|
|
|
// @ts-expect-error legacy noImplicitAny
|
|
return res.map((column) => ({
|
|
columnName: column.column_name,
|
|
dataType: column.data_type,
|
|
udtName: column.udt_name,
|
|
}));
|
|
};
|