File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ class OnExecuteNestedQueryable {
4141 // try to upgrade
4242 return model . migrateAsync ( ) ;
4343 }
44+ if ( model == null ) {
45+ // try to find if the given model is a pre-defined many-to-many association
46+ const attribute = event . model . attributes . filter ( ( attr ) => attr . many ) . find ( ( attr ) => {
47+ const mapping = event . model . inferMapping ( attr . name ) ;
48+ return mapping && mapping . associationAdapter === item . $entity . model ;
49+ } ) ;
50+ if ( attribute ) {
51+ /**
52+ * use DataObjectJunction class as a helper for creating model
53+ * (get an instance of DataObjectJunction class using DataObject.property() method)
54+ * @type {import('./data-object-junction').DataObjectJunction }
55+ */
56+ const junction = event . model . convert ( { } ) . property ( attribute . name ) ;
57+ return junction . getBaseModel ( ) . migrateAsync ( ) ;
58+ }
59+ }
4460 }
4561 return Promise . resolve ( ) ;
4662 }
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ var { DataModel } = require('./data-model');
3939 */
4040function DefaultDataContext ( )
4141{
42+ DefaultDataContext . super_ . bind ( this ) ( ) ;
4243 /**
4344 * @type {import('./types').DataAdapter }
4445 */
You can’t perform that action at this time.
0 commit comments