File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
packages/orm/src/client/helpers
tests/e2e/orm/query-builder Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,9 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
2323 await this . kysely . transaction ( ) . execute ( async ( tx ) => {
2424 if ( this . schema . enums && this . schema . provider . type === 'postgresql' ) {
2525 for ( const [ name , enumDef ] of Object . entries ( this . schema . enums ) ) {
26- const createEnum = tx . schema . createType ( name ) . asEnum (
27- Object . values ( enumDef . fields ?? { } ) . map ( ( f ) => {
26+ let enumValues : string [ ] ;
27+ if ( enumDef . fields ) {
28+ enumValues = Object . values ( enumDef . fields ) . map ( ( f ) => {
2829 const mapAttr = f . attributes ?. find ( ( a ) => a . name === '@map' ) ;
2930 if ( ! mapAttr || ! mapAttr . args ?. [ 0 ] ) {
3031 return f . name ;
@@ -36,8 +37,12 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
3637 ) ;
3738 return mappedName ;
3839 }
39- } ) ,
40- ) ;
40+ } ) ;
41+ } else {
42+ enumValues = Object . values ( enumDef . values ) ;
43+ }
44+
45+ const createEnum = tx . schema . createType ( name ) . asEnum ( enumValues ) ;
4146 await createEnum . execute ( ) ;
4247 }
4348 }
Original file line number Diff line number Diff line change 11import { createId } from '@paralleldrive/cuid2' ;
2+ import { createTestClient } from '@zenstackhq/testtools' ;
23import { describe , expect , it } from 'vitest' ;
34import { getSchema } from '../schemas/basic' ;
4- import { createTestClient } from '@zenstackhq/testtools' ;
55
66describe ( 'Client API tests' , ( ) => {
77 const schema = getSchema ( 'sqlite' ) ;
You can’t perform that action at this time.
0 commit comments