File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
test/integration/associations Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,21 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
381
381
} ) ;
382
382
} ) ;
383
383
384
+ it ( 'works when cascading a delete with hooks but there is no associate (i.e. "has zero")' , function ( ) {
385
+ var Task = this . sequelize . define ( 'Task' , { title : Sequelize . STRING } )
386
+ , User = this . sequelize . define ( 'User' , { username : Sequelize . STRING } ) ;
387
+
388
+ User . hasOne ( Task , { onDelete : 'cascade' , hooks : true } ) ;
389
+
390
+ return User . sync ( { force : true } ) . then ( function ( ) {
391
+ return Task . sync ( { force : true } ) . then ( function ( ) {
392
+ return User . create ( { username : 'foo' } ) . then ( function ( user ) {
393
+ return user . destroy ( ) ;
394
+ } ) ;
395
+ } ) ;
396
+ } ) ;
397
+ } ) ;
398
+
384
399
// NOTE: mssql does not support changing an autoincrement primary key
385
400
if ( Support . getTestDialect ( ) !== 'mssql' ) {
386
401
it ( 'can cascade updates' , function ( ) {
You can’t perform that action at this time.
0 commit comments