@@ -20,6 +20,7 @@ export const apply = ({
20
20
functions,
21
21
types,
22
22
arrayTypes,
23
+ detectOneToOneRelationships,
23
24
} : {
24
25
schemas : PostgresSchema [ ]
25
26
tables : Omit < PostgresTable , 'columns' > [ ]
@@ -30,6 +31,7 @@ export const apply = ({
30
31
functions : PostgresFunction [ ]
31
32
types : PostgresType [ ]
32
33
arrayTypes : PostgresType [ ]
34
+ detectOneToOneRelationships : boolean
33
35
} ) : string => {
34
36
const columnsByTableId = columns
35
37
. sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
@@ -169,8 +171,11 @@ export interface Database {
169
171
( relationship ) => `{
170
172
foreignKeyName: ${ JSON . stringify ( relationship . foreign_key_name ) }
171
173
columns: ${ JSON . stringify ( relationship . columns ) }
172
- isOneToOne: ${ relationship . is_one_to_one }
173
- referencedRelation: ${ JSON . stringify ( relationship . referenced_relation ) }
174
+ ${
175
+ detectOneToOneRelationships
176
+ ? `isOneToOne: ${ relationship . is_one_to_one } ;`
177
+ : ''
178
+ } referencedRelation: ${ JSON . stringify ( relationship . referenced_relation ) }
174
179
referencedColumns: ${ JSON . stringify ( relationship . referenced_columns ) }
175
180
}`
176
181
) }
@@ -238,8 +243,11 @@ export interface Database {
238
243
( relationship ) => `{
239
244
foreignKeyName: ${ JSON . stringify ( relationship . foreign_key_name ) }
240
245
columns: ${ JSON . stringify ( relationship . columns ) }
241
- isOneToOne: ${ relationship . is_one_to_one }
242
- referencedRelation: ${ JSON . stringify ( relationship . referenced_relation ) }
246
+ ${
247
+ detectOneToOneRelationships
248
+ ? `isOneToOne: ${ relationship . is_one_to_one } ;`
249
+ : ''
250
+ } referencedRelation: ${ JSON . stringify ( relationship . referenced_relation ) }
243
251
referencedColumns: ${ JSON . stringify ( relationship . referenced_columns ) }
244
252
}`
245
253
) }
0 commit comments