perspective defaults - FK columns

This commit is contained in:
Jan Prochazka
2022-07-28 20:43:03 +02:00
parent 513b2ba42f
commit d3a40e52fc
3 changed files with 10 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import { findForeignKeyForColumn } from 'dbgate-tools';
import { DatabaseInfo, TableInfo } from 'dbgate-types';
export function getPerspectiveDefaultColumns(table: TableInfo, db: DatabaseInfo): string[] {
@@ -8,6 +9,7 @@ export function getPerspectiveDefaultColumns(table: TableInfo, db: DatabaseInfo)
x => x.toLowerCase().includes('name'),
x => x.toLowerCase().includes('title'),
x => x.dataType?.toLowerCase()?.includes('char'),
x => findForeignKeyForColumn(table, x)?.columns?.length == 1,
];
for (const predicate of predicates) {