Add query for the relation's ID, but then remove it from results. Remove ID when unloading.
969120
public function beforeLoad($m, $q = null)
    {
        if (is_null($q)) {
            return;
        }  // manual load

        if ($this->m2 && $this->m2 != $this->owner->id_field) {
            $q->field($this->m2, $this->m1, $this->short_name);
        } elseif ($this->m2) {
            $q->field($this->f2, $this->fa ?: $this->f1, $this->short_name);
        }
    }
931706
def remove(self, index):
        '''
        
        '''
        raise NotImplementedError
        if hasattr(index, '__iter__'):
            ind = set(index)
        else:
            ind = [index]

        # Rebuild relationships, excluding the provided indices
        self._relationships = [r for i, r in enumerate(self._relationships) if i not in ind]
818317
def delete_relation(sender, instance, **kwargs):
    """"""
    def process_signal(relation_id):
        """Get the relation and delete it if it has no entities left."""
        try:
            relation = Relation.objects.get(pk=relation_id)
        except Relation.DoesNotExist:
            return

        if relation.entities.count() == 0:
            relation.delete()

    # Wait for partitions to be recreated.
    transaction.on_commit(lambda: process_signal(instance.relation_id))
1156984
public function removeIDFilterIfNeeded()
    {
        if (!$this->useIdFilter && !$this->idFilterRemoved) {
            $this->removeDefaultIDFilter();

            $this->layout->removeDefaultIDFilter();

            $this->idFilterRemoved = true;
        }
    }
372062
def delete_source(self, id):
        
        # Set the index
        self.catalog.set_index('id')
        
        # Exclude the unwanted source
        self.catalog = self.catalog[self.catalog.id!=id]
        
        # Remove the records from the catalogs
        for cat_name in self.catalogs:
            new_cat = getattr(self, cat_name)[getattr(self, cat_name).source_id!=id]
            print('{} records removed from {} catalog'.format(int(len(getattr(self, cat_name))-len(new_cat)), cat_name))
            setattr(self, cat_name, new_cat)
569231
def remove(self, id):
        

        # find prefix
        c.prefix = Prefix.get(int(id))

        if 'confirmed' not in request.params:
            return render('/prefix_remove_confirm.html')

        c.prefix.remove()
        redirect(url(controller='prefix', action='list'))
970952
def delete(cls, id):
        '''
        
        '''
        client = cls._new_api_client()
        return client.make_request(cls, 'delete', url_params={'id': id})
281898
function removeThis( $id = false )
    {
        $db = eZDB::instance();
        $db->begin();
        foreach ( $this->attribute( 'limitations' ) as $limitation )
        {
            $limitation->removeThis();
        }
        $db->query( "DELETE FROM ezpolicy
                     WHERE id='" . $db->escapeString( $this->attribute( 'id' ) ) . "'" );
        $db->commit();
    }
1237574
def remove_query_param(self, key, value=None):
        
        parse_result = self.query_params()
        if value is not None:
            index = parse_result[key].index(value)
            del parse_result[key][index]
        else:
            del parse_result[key]
        return URL._mutate(self, query=unicode_urlencode(parse_result, doseq=True))
273637
def relation_clear(r_id=None):
    '''  '''
    settings = relation_get(rid=r_id,
                            unit=local_unit())
    for setting in settings:
        if setting not in ['public-address', 'private-address']:
            settings[setting] = None
    relation_set(relation_id=r_id,
                 **settings)
415913
def remove(self, _query=None, **kwargs):
        
        for entry in self._find_entries(_query=_query, **kwargs):
            self._service.DeleteRow(entry)
482362
def filter_delete(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/filters/{0}'.format(str(id))
        self.__api_request('DELETE', url)
78254
def remove(self, db):
        
        assert self.collection
        assert self.id

        db[self.collection].remove(self.id)
1224663
def delete(self):
        
        del_query = self._clone()

        # The delete is actually 2 queries - one to find related objects,
        # and one to delete. Make sure that the discovery of related
        # objects is performed on the same database as the deletion.
        del_query._clear_ordering()
        connection = self.model._meta.dj_connection

        connection.connection.delete_by_query(indices=connection.database, doc_types=self.model._meta.db_table,
                                              query=del_query._build_query())
        connection.connection.indices.refresh(indices=connection.database)
        # Clear the result cache, in case this QuerySet gets reused.
        self._result_cache = None
1252903
def __remove_activity(self, id):
        

        query = "select count(*) as count from facts where activity_id = ?"
        bound_facts = self.fetchone(query, (id,))['count']

        if bound_facts > 0:
            self.execute("UPDATE activities SET deleted = 1 WHERE id = ?", (id,))
        else:
            self.execute("delete from activities where id = ?", (id,))
1023275
def filter(self, *args, **kwargs):
		""""""
		if 'pk' in kwargs or 'id' in kwargs:
			return self.all_with_deleted().filter(*args, **kwargs)
		return self.get_query_set().filter(*args, **kwargs)
361681
public function beforeDelete()
    {
        /** @var BaseActiveRecord $owner */
        $owner = $this->owner;
        foreach ($this->_relationsCascadeDelete as $relationName => $params) {
            if ($params === true) {
                /** @var ActiveQuery $relation */
                $relation = $owner->getRelation($relationName);
                if (!empty($owner->{$relationName})) {
                    if ($relation->multiple === true) { // Has many relation
                        $this->_relationsToDelete = ArrayHelper::merge($this->_relationsToDelete, $owner->{$relationName});
                    } else {
                        $this->_relationsToDelete[] = $owner->{$relationName};
                    }
                }
            }
        }
    }