<commit_before><?php

class ComAttachmentsDatabaseRowAttachment extends KDatabaseRowDefault
{
	public function save()
	{
		$return = parent::save();
			
		if ($return && $this->row && $this->table) {
			$relation = $this->getService('com://admin/attachments.database.row.relation');
			$relation->attachments_attachment_id = $this->id;
			$relation->table = $this->table;
			$relation->row = $this->row;

			if(!$relation->load()) {
				$relation->save();
			}
		}
		
		return $return;
	}
	
	public function delete()
	{
		$return = parent::delete();
			
		if ($return) {
			$controller = $this->getService('com://admin/files.controller.file', array(
				'request' => array('container' => $this->container)
			));
			$controller->delete(array('name' => $this->path));
			
			$relations = $this->getService('com://admin/attachments.database.table.relations')
				->select(array('attachments_attachment_id' => $this->id));
			$relations->delete();
		}

		return $return;
	}
	
	public function __get($name)
	{
	    if($name == 'relation' && is_null($this->relation))
	    {
	        $this->relation = $this->getService('com://admin/attachments.database.table.relations')
	            ->select(array('attachments_attachment_id' => $this->id), KDatabase::FETCH_ROW);
	    }
	    
	    return parent::__get($name);
	}
}<commit_msg>Fixed problem with attachments delete. Name column is set as identity_column on nodes rowsets. Therefore file rowsets cannot (and shouldn't for improving performance) be filtered using setData using the name column. Instead the model should be asked to directly provide the row using the name model state by setting it in the request.<commit_after><?php

class ComAttachmentsDatabaseRowAttachment extends KDatabaseRowDefault
{
	public function save()
	{
		$return = parent::save();
			
		if ($return && $this->row && $this->table) {
			$relation = $this->getService('com://admin/attachments.database.row.relation');
			$relation->attachments_attachment_id = $this->id;
			$relation->table = $this->table;
			$relation->row = $this->row;

			if(!$relation->load()) {
				$relation->save();
			}
		}
		
		return $return;
	}
	
	public function delete()
	{
		$return = parent::delete();
			
		if ($return) {
			$this->getService('com://admin/files.controller.file', array(
				'request' => array('container' => $this->container, 'name' => $this->path)
			))->delete();
						
			$relations = $this->getService('com://admin/attachments.database.table.relations')
				->select(array('attachments_attachment_id' => $this->id));
			$relations->delete();
		}

		return $return;
	}
	
	public function __get($name)
	{
	    if($name == 'relation' && is_null($this->relation))
	    {
	        $this->relation = $this->getService('com://admin/attachments.database.table.relations')
	            ->select(array('attachments_attachment_id' => $this->id), KDatabase::FETCH_ROW);
	    }
	    
	    return parent::__get($name);
	}
}
{'fraction_non_alphanumeric': 0.17432754511406195, 'fraction_numerical': 0.0, 'mean_word_length': 3.7463651050080777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5109369', 'n_tokens_mistral': 1027, 'n_tokens_neox': 888, 'n_words': 175}