public function delete($query)
    {
        $resources = $query->getRepository()->getResources();

        foreach ($resources->getLinks() as $link) {
            $query->where($link->child, '=', $link->parent);
        }

        $names = array();

        foreach ($resources as $resource) {
            $query->from($resource->getName().' AS '.$this->_store->quoteName($resource->getAlias()));
            $names[] = $this->_store->quoteName($resource->getAlias());
        }

        $clause = 'DELETE '.implode(', ', $names);

        return $clause;
    }