File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -44,22 +44,23 @@ export function oneToOne<Source extends State, Target extends State>(
44
44
const foreignKey = options ?. foreignKey ?? getDefaultFK ( this , target ) ;
45
45
46
46
// sequelize is not creating fk when fk = pk
47
- foreignKey === target . primaryKeyAttribute
48
- ? mapFk (
49
- target ,
50
- this ,
51
- { primaryKey : [ this . primaryKeyAttribute ] , foreignKey : [ foreignKey ] } ,
52
- {
53
- onUpdate : options ?. onUpdate ?? 'NO ACTION' ,
54
- onDelete : options ?. onDelete ?? 'NO ACTION' ,
55
- } ,
56
- )
57
- : target . belongsTo ( this , {
58
- foreignKey,
59
- as : options ?. as ,
47
+ if ( foreignKey === target . primaryKeyAttribute )
48
+ mapFk (
49
+ target ,
50
+ this ,
51
+ { primaryKey : [ this . primaryKeyAttribute ] , foreignKey : [ foreignKey ] } ,
52
+ {
60
53
onUpdate : options ?. onUpdate ?? 'NO ACTION' ,
61
54
onDelete : options ?. onDelete ?? 'NO ACTION' ,
62
- } ) ;
55
+ } ,
56
+ ) ;
57
+
58
+ target . belongsTo ( this , {
59
+ foreignKey,
60
+ as : options ?. as ,
61
+ onUpdate : options ?. onUpdate ?? 'NO ACTION' ,
62
+ onDelete : options ?. onDelete ?? 'NO ACTION' ,
63
+ } ) ;
63
64
64
65
options ?. targeyKey &&
65
66
this . belongsTo ( target , {
You can’t perform that action at this time.
0 commit comments