Skip to content

Commit 2ad8857

Browse files
authored
fix: support custom types in db pusher (#184)
1 parent 9139e3f commit 2ad8857

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [ ] ZModel
1717
- [x] Import
1818
- [ ] View support
19+
- [ ] Datasource provider-scoped attributes
1920
- [ ] ORM
2021
- [x] Create
2122
- [x] Input validation

packages/runtime/src/client/helpers/schema-db-pusher.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
188188
return 'serial';
189189
}
190190

191+
if (this.isCustomType(fieldDef.type)) {
192+
return 'jsonb';
193+
}
194+
191195
const type = fieldDef.type as BuiltinType;
192196
const result = match<BuiltinType, ColumnDataType>(type)
193197
.with('String', () => 'text')
@@ -211,6 +215,10 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
211215
}
212216
}
213217

218+
private isCustomType(type: string) {
219+
return this.schema.typeDefs && Object.values(this.schema.typeDefs).some((def) => def.name === type);
220+
}
221+
214222
private isAutoIncrement(fieldDef: FieldDef) {
215223
return (
216224
fieldDef.default &&

0 commit comments

Comments
 (0)