Don't need NOT IN conditions when there are no primary keys found
This commit is contained in:
		
							parent
							
								
									9a63fb28ba
								
							
						
					
					
						commit
						934e97b018
					
				@ -156,9 +156,11 @@ func (association *Association) Replace(values ...interface{}) *Association {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			newPrimaryKeys = association.getPrimaryKeys(associationForeignFieldNames, field.Interface())
 | 
								newPrimaryKeys = association.getPrimaryKeys(associationForeignFieldNames, field.Interface())
 | 
				
			||||||
 | 
								if len(newPrimaryKeys) > 0 {
 | 
				
			||||||
				sql := fmt.Sprintf("%v NOT IN (%v)", toQueryCondition(scope, relationship.AssociationForeignDBNames), toQueryMarks(newPrimaryKeys))
 | 
									sql := fmt.Sprintf("%v NOT IN (%v)", toQueryCondition(scope, relationship.AssociationForeignDBNames), toQueryMarks(newPrimaryKeys))
 | 
				
			||||||
				newDB = newDB.Where(sql, toQueryValues(newPrimaryKeys)...)
 | 
									newDB = newDB.Where(sql, toQueryValues(newPrimaryKeys)...)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if relationship.Kind == "many_to_many" {
 | 
							if relationship.Kind == "many_to_many" {
 | 
				
			||||||
			association.setErr(relationship.JoinTableHandler.Delete(relationship.JoinTableHandler, newDB, relationship))
 | 
								association.setErr(relationship.JoinTableHandler.Delete(relationship.JoinTableHandler, newDB, relationship))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user