@@ -554,8 +554,7 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
554554 }
555555
556556 if ( fromRelation && m2m ) {
557- // connect many-to-many relation; mark the newly created model so the
558- // policy plugin can skip the circular update-policy check on it
557+ // connect many-to-many relation
559558 await this . handleManyToManyRelation (
560559 kysely ,
561560 'connect' ,
@@ -566,7 +565,6 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
566565 m2m . otherField ,
567566 [ createdEntity ] ,
568567 m2m . joinTable ,
569- m2m . otherModel ,
570568 ) ;
571569 }
572570
@@ -649,10 +647,6 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
649647 return parentFkFields ;
650648 }
651649
652- // Marker embedded in the INSERT end modifier to signal to the policy plugin
653- // that one side of the join was just created in this operation.
654- static readonly M2M_CREATED_MODEL_MARKER_PREFIX = '/*ZS:M2M_CREATED:' ;
655-
656650 private async handleManyToManyRelation < Action extends 'connect' | 'disconnect' > (
657651 kysely : AnyKysely ,
658652 action : Action ,
@@ -663,7 +657,6 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
663657 rightField : string ,
664658 rightEntities : any [ ] ,
665659 joinTable : string ,
666- newlyCreatedModel ?: string ,
667660 ) : Promise < void > {
668661 if ( rightEntities . length === 0 ) {
669662 return ;
@@ -701,14 +694,6 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
701694 )
702695 // case for `INSERT IGNORE` syntax
703696 . $if ( this . dialect . insertIgnoreMethod === 'ignore' , ( qb ) => qb . ignore ( ) )
704- // embed a marker so the policy plugin knows which model was just created
705- . $if ( newlyCreatedModel !== undefined , ( qb ) =>
706- qb . modifyEnd (
707- sql . raw (
708- `${ BaseOperationHandler . M2M_CREATED_MODEL_MARKER_PREFIX } ${ newlyCreatedModel } */` ,
709- ) ,
710- ) ,
711- )
712697 . execute ( ) ;
713698 } else {
714699 const eb = expressionBuilder < any , any > ( ) ;
@@ -844,9 +829,7 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
844829 }
845830
846831 case 'connect' : {
847- // contextModel was just created; pass it so the policy plugin can
848- // skip the circular update-policy check on the newly created side
849- await this . connectRelation ( kysely , relationModel , subPayload , fromRelationContext , contextModel ) ;
832+ await this . connectRelation ( kysely , relationModel , subPayload , fromRelationContext ) ;
850833 break ;
851834 }
852835
@@ -856,7 +839,7 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
856839 if ( ! found ) {
857840 await this . create ( kysely , relationModel , item . create , fromRelationContext ) ;
858841 } else {
859- await this . connectRelation ( kysely , relationModel , found , fromRelationContext , contextModel ) ;
842+ await this . connectRelation ( kysely , relationModel , found , fromRelationContext ) ;
860843 }
861844 }
862845 break ;
@@ -1927,13 +1910,7 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
19271910
19281911 // #region relation manipulation
19291912
1930- protected async connectRelation (
1931- kysely : AnyKysely ,
1932- model : string ,
1933- data : any ,
1934- fromRelation : FromRelationContext ,
1935- newlyCreatedModel ?: string ,
1936- ) {
1913+ protected async connectRelation ( kysely : AnyKysely , model : string , data : any , fromRelation : FromRelationContext ) {
19371914 const _data = this . normalizeRelationManipulationInput ( model , data ) ;
19381915 if ( _data . length === 0 ) {
19391916 return ;
@@ -1956,7 +1933,6 @@ export abstract class BaseOperationHandler<Schema extends SchemaDef> {
19561933 m2m . otherField ! ,
19571934 allIds ,
19581935 m2m . joinTable ,
1959- newlyCreatedModel ,
19601936 ) ;
19611937 } else {
19621938 const { ownedByModel, keyPairs } = getRelationForeignKeyFieldPairs (
0 commit comments