Skip to content

Commit

Permalink
feat: introduce columnNames convenience object
Browse files Browse the repository at this point in the history
  • Loading branch information
shah committed Jan 7, 2024
1 parent f6533d9 commit 310f3fa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions render/ddl/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ export function tableDefinition<
[Property in keyof ColumnsShape]: (ctx: Context) => string;
};

type ColumnIdentities = {
[Property in keyof ColumnsShape]: Property;
};

const domains = tableShapeKeys.map((key) =>
fkf.zbSchema[key].sqlDomain as c.TableColumnDefn<
TableName,
Expand Down Expand Up @@ -243,6 +247,7 @@ export function tableDefinition<
const afterColumnDefnsSS: tmpl.SqlTextSupplier<Context>[] = [];
const constraints: con.TableColumnsConstraint<ColumnsShape, Context>[] = [];
const indexes: idx.TableColumnsIndex<ColumnsShape, Context>[] = [];
const columnIdentities: ColumnIdentities = {} as Any;
const symbolSuppliers: SqlSymbolSuppliersSchema = {} as Any;
const symbols: SqlSymbolsSchema = {} as Any;

Expand All @@ -256,6 +261,7 @@ export function tableDefinition<
unique[column.identity as (keyof UniqueColumnDefns)] = column as Any;
constraints.push(con.uniqueConstraint(column.identity));
}
(columnIdentities[column.identity] as Any) = column.identity;
(symbolSuppliers[column.identity] as Any) = { sqlSymbol: column.sqlSymbol };
(symbols[column.identity] as Any) = column.sqlSymbol;
}
Expand Down Expand Up @@ -404,6 +410,7 @@ export function tableDefinition<
& {
readonly domains: typeof domains;
readonly columns: ColumnDefns;
readonly columnNames: ColumnIdentities;
readonly symbolSuppliers: SqlSymbolSuppliersSchema;
readonly symbols: SqlSymbolsSchema;
readonly primaryKey: PrimaryKeys;
Expand Down Expand Up @@ -467,6 +474,7 @@ export function tableDefinition<
},
graphEntityDefn,
domains,
columnNames: columnIdentities,
symbolSuppliers,
symbols,
columns,
Expand Down

0 comments on commit 310f3fa

Please sign in to comment.