@@ -38,9 +38,15 @@ model Foo {
3838 const foundSchema = { create : false , read : false , update : false , delete : false } ;
3939 const db = await createTestClient (
4040 `
41+ enum Role {
42+ ADMIN
43+ USER
44+ }
45+
4146model Foo {
4247 id Int @id
4348 name String
49+ role Role
4450}
4551` ,
4652 {
@@ -57,7 +63,9 @@ model Foo {
5763 } ,
5864 ) ;
5965
60- await expect ( db . $qb . insertInto ( 'Foo' ) . values ( { id : 1 , name : 'test' } ) . execute ( ) ) . toResolveTruthy ( ) ;
66+ await expect (
67+ db . $qb . insertInto ( 'Foo' ) . values ( { id : 1 , name : 'test' , role : 'ADMIN' } ) . execute ( ) ,
68+ ) . toResolveTruthy ( ) ;
6169 await expect ( db . $qb . selectFrom ( 'Foo' ) . selectAll ( ) . executeTakeFirst ( ) ) . toResolveTruthy ( ) ;
6270 await expect (
6371 db . $qb . updateTable ( 'Foo' ) . set ( { name : 'updated' } ) . where ( 'id' , '=' , 1 ) . execute ( ) ,
@@ -75,17 +83,23 @@ datasource db {
7583 defaultSchema = 'mySchema'
7684}
7785
86+ enum Role {
87+ ADMIN
88+ USER
89+ }
90+
7891model Foo {
7992 id Int @id
8093 name String
94+ role Role
8195}
8296` ,
8397 {
8498 provider : 'postgresql' ,
8599 } ,
86100 ) ;
87101
88- await expect ( db . foo . create ( { data : { id : 1 , name : 'test' } } ) ) . rejects . toSatisfy (
102+ await expect ( db . foo . create ( { data : { id : 1 , name : 'test' , role : 'ADMIN' } } ) ) . rejects . toSatisfy (
89103 ( e ) => e instanceof ORMError && ! ! e . dbErrorMessage ?. includes ( 'relation "mySchema.Foo" does not exist' ) ,
90104 ) ;
91105
@@ -98,17 +112,23 @@ datasource db {
98112 defaultSchema = 'public'
99113}
100114
115+ enum Role {
116+ ADMIN
117+ USER
118+ }
119+
101120model Foo {
102121 id Int @id
103122 name String
123+ role Role
104124}
105125` ,
106126 {
107127 provider : 'postgresql' ,
108128 } ,
109129 ) ;
110130
111- await expect ( db1 . foo . create ( { data : { id : 1 , name : 'test' } } ) ) . toResolveTruthy ( ) ;
131+ await expect ( db1 . foo . create ( { data : { id : 1 , name : 'test' , role : 'ADMIN' } } ) ) . toResolveTruthy ( ) ;
112132 } ) ;
113133
114134 it ( 'supports custom schemas' , async ( ) => {
@@ -123,15 +143,29 @@ datasource db {
123143 url = '$DB_URL'
124144}
125145
146+ enum FooRole {
147+ ADMIN
148+ USER
149+ @@schema('mySchema')
150+ }
151+
126152model Foo {
127153 id Int @id
128154 name String
155+ role FooRole
129156 @@schema('mySchema')
130157}
131158
159+ enum BarRole {
160+ ADMIN
161+ USER
162+ @@schema('public')
163+ }
164+
132165model Bar {
133166 id Int @id
134167 name String
168+ role BarRole
135169 @@schema('public')
136170}
137171` ,
@@ -150,8 +184,8 @@ model Bar {
150184 } ,
151185 ) ;
152186
153- await expect ( db . foo . create ( { data : { id : 1 , name : 'test' } } ) ) . toResolveTruthy ( ) ;
154- await expect ( db . bar . create ( { data : { id : 1 , name : 'test' } } ) ) . toResolveTruthy ( ) ;
187+ await expect ( db . foo . create ( { data : { id : 1 , name : 'test' , role : 'ADMIN' } } ) ) . toResolveTruthy ( ) ;
188+ await expect ( db . bar . create ( { data : { id : 1 , name : 'test' , role : 'USER' } } ) ) . toResolveTruthy ( ) ;
155189
156190 expect ( fooQueriesVerified ) . toBe ( true ) ;
157191 expect ( barQueriesVerified ) . toBe ( true ) ;
@@ -226,9 +260,15 @@ datasource db {
226260 url = '$DB_URL'
227261}
228262
263+ enum Role {
264+ ADMIN
265+ USER
266+ }
267+
229268model Foo {
230269 id Int @id
231270 name String
271+ role Role
232272 @@schema('mySchema')
233273}
234274
@@ -252,7 +292,7 @@ model Bar {
252292 } ,
253293 ) ;
254294
255- await expect ( db . foo . create ( { data : { id : 1 , name : 'test' } } ) ) . toResolveTruthy ( ) ;
295+ await expect ( db . foo . create ( { data : { id : 1 , name : 'test' , role : 'ADMIN' } } ) ) . toResolveTruthy ( ) ;
256296 await expect ( db . bar . create ( { data : { id : 1 , name : 'test' } } ) ) . toResolveTruthy ( ) ;
257297
258298 expect ( fooQueriesVerified ) . toBe ( true ) ;
0 commit comments