Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass Undefined Columns in ExtrConfigColumns #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"typings": "dist/index.d.ts",
"type": "module",
"scripts": {
"prepare": "npm run build",
"build": "npx tsup src/index.ts --format cjs,esm --dts",
"fmt": "npx prettier --write .",
"lint": "npx eslint . && npx tsc --noEmit",
Expand Down Expand Up @@ -40,4 +41,4 @@
"dependencies": {
"drizzle-orm": "^0.32.0"
}
}
}
2 changes: 1 addition & 1 deletion src/generators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export abstract class BaseGenerator<
}
const extraConfigBuilder = table[ExtraConfigBuilder];
const extraConfigColumns = table[ExtraConfigColumns];
const extraConfig = extraConfigBuilder?.(extraConfigColumns ?? {});
const extraConfig = extraConfigColumns ? extraConfigBuilder?.(extraConfigColumns ?? {}) : {};

const builtIndexes = Object.values(extraConfig ?? {}).map((b: AnyBuilder) => b.build(table));
const fks = builtIndexes.filter(
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function formatList(

export function wrapColumns(columns: AnyColumn[], escapeName: (name: string) => string) {
const formatted = formatList(
columns.map((column) => column.name),
columns.filter((column) => column !== undefined).map((column) => column.name),
escapeName,
true
);
Expand Down