Skip to content

Commit 9b23102

Browse files
committed
fix(lib/columns): remove is_nullable default value
1 parent e06449e commit 9b23102

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/PostgresMetaColumns.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export default class PostgresMetaColumns {
8585
default_value_format = 'literal',
8686
is_identity = false,
8787
identity_generation = 'BY DEFAULT',
88-
is_nullable = true,
88+
// Can't pick a value as default since regular columns are nullable by default but PK columns aren't
89+
is_nullable,
8990
is_primary_key = false,
9091
is_unique = false,
9192
comment,
@@ -119,7 +120,10 @@ export default class PostgresMetaColumns {
119120
defaultValueClause = `DEFAULT ${literal(default_value)}`
120121
}
121122
const isIdentityClause = is_identity ? `GENERATED ${identity_generation} AS IDENTITY` : ''
122-
const isNullableClause = is_nullable ? 'NULL' : 'NOT NULL'
123+
let isNullableClause = ''
124+
if (is_nullable !== undefined) {
125+
isNullableClause = is_nullable ? 'NULL' : 'NOT NULL'
126+
}
123127
const isPrimaryKeyClause = is_primary_key ? 'PRIMARY KEY' : ''
124128
const isUniqueClause = is_unique ? 'UNIQUE' : ''
125129
const checkSql = check === undefined ? '' : `CHECK (${check})`

0 commit comments

Comments
 (0)