File tree 2 files changed +15
-2
lines changed 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ class Property extends BaseProperty {
73
73
if ( this . sequelizePath . references === 'string' ) {
74
74
return this . sequelizePath . references as string ;
75
75
} if ( this . sequelizePath . references && typeof this . sequelizePath . references !== 'string' ) {
76
+ // Sequelize v7
77
+ if ( ( this . sequelizePath . references as any ) . table ?. tableName ) {
78
+ return ( this . sequelizePath . references as any ) . table ?. tableName as string ;
79
+ }
80
+ // Sequelize v4+
76
81
if ( this . sequelizePath . references . model && typeof this . sequelizePath . references . model !== 'string' ) {
77
82
return ( this . sequelizePath . references ?. model as any ) ?. tableName as string ;
78
83
}
Original file line number Diff line number Diff line change @@ -37,9 +37,11 @@ class Resource extends BaseResource {
37
37
38
38
rawAttributes ( ) : Record < string , ModelAttributeColumnOptions > {
39
39
// different sequelize versions stores attributes in different places
40
+ // .modelDefinition.attributes => sequelize ^7.0.0
40
41
// .rawAttributes => sequelize ^5.0.0
41
42
// .attributes => sequelize ^4.0.0
42
43
return ( ( this . SequelizeModel as any ) . attributes
44
+ || ( ( this . SequelizeModel as any ) . modelDefinition ?. attributes && Object . fromEntries ( ( this . SequelizeModel as any ) . modelDefinition ?. attributes ) )
43
45
|| ( this . SequelizeModel as any ) . rawAttributes ) as Record < string , ModelAttributeColumnOptions > ;
44
46
}
45
47
@@ -54,11 +56,17 @@ class Resource extends BaseResource {
54
56
}
55
57
56
58
name ( ) : string {
57
- return this . SequelizeModel . tableName ;
59
+ // different sequelize versions stores attributes in different places
60
+ // .modelDefinition.table => sequelize ^7.0.0
61
+ // .tableName => sequelize ^4.0.0
62
+ return (
63
+ ( this . SequelizeModel as any ) . modelDefinition ?. table ?. tableName
64
+ || this . SequelizeModel . tableName
65
+ ) ;
58
66
}
59
67
60
68
id ( ) : string {
61
- return this . SequelizeModel . tableName ;
69
+ return this . name ( ) ;
62
70
}
63
71
64
72
properties ( ) : Array < BaseProperty > {
You can’t perform that action at this time.
0 commit comments