<commit_before><?php

namespace tunecino\builder\models;

use Yii;
use yii\db\Schema;


class Attribute extends \yii2tech\filedb\ActiveRecord
{
	const SCENARIO_JUNCTION = 'junction';


	public static function getDb()
	{
		return \tunecino\builder\Module::getInstance()->get('filedb');
	}

	public function attributes()
	{
		return array_keys($this->attributeLabels());
	}


	public function rules()
	{
		return [
			[['name', 'type', 'entity_id'], 'required'],
			['type', 'in', 'range' => array_keys($this->types)],
			[['required', 'unique'], 'boolean'],
			[['entity_id', 'name', 'type', 'default'], 'string'],
			['name', 'unique', 'targetAttribute' => ['name', 'entity_id'], 'comboNotUnique' => 'Attribute "{value}" has already been defined.'],
			['entity_id', 'exist', 'skipOnError' => true, 'targetClass' => Entity::className(), 'targetAttribute' => ['entity_id' => 'id'], 'on' => self::SCENARIO_DEFAULT],
			['entity_id', 'exist', 'skipOnError' => true, 'targetClass' => Relationship::className(), 'targetAttribute' => ['entity_id' => 'id'], 'on' => self::SCENARIO_JUNCTION],
			['entity_id', 'validateJunctionRelation', 'on' => self::SCENARIO_JUNCTION],
			['length', 'integer', 'when' => function($model) {return $model->lengthRequired();}],
			['precision', 'integer', 'when' => function($model) {return $model->precisionRequired();}],
			['scale', 'integer', 'when' => function($model) {return $model->scaleRequired();}],
		];
	}


	public function validateJunctionRelation($attribute, $params)
	{
		if ($this->relationship->isManyToMany() === false) 
			$this->addError($attribute, "Entities to share this attribute are not sharing a many_to_many relationship");
	}
<commit_msg>temporary disable creation of primary keys<commit_after><?php

namespace tunecino\builder\models;

use Yii;
use yii\db\Schema;


class Attribute extends \yii2tech\filedb\ActiveRecord
{
	const SCENARIO_JUNCTION = 'junction';


	public static function getDb()
	{
		return \tunecino\builder\Module::getInstance()->get('filedb');
	}

	public function attributes()
	{
		return array_keys($this->attributeLabels());
	}


	public function rules()
	{
		return [
			[['name', 'type', 'entity_id'], 'required'],
			['type', 'in', 'range' => array_keys($this->types)],
			[['required', 'unique'], 'boolean'],
			[['entity_id', 'name', 'type', 'default'], 'string'],
			['name', 'compare', 'compareValue' => 'id', 'operator' => '!=', 'message' => 'Primary key will be added automatically. No need to create it.'],
			['name', 'unique', 'targetAttribute' => ['name', 'entity_id'], 'comboNotUnique' => 'Attribute "{value}" has already been defined.'],
			['entity_id', 'exist', 'skipOnError' => true, 'targetClass' => Entity::className(), 'targetAttribute' => ['entity_id' => 'id'], 'on' => self::SCENARIO_DEFAULT],
			['entity_id', 'exist', 'skipOnError' => true, 'targetClass' => Relationship::className(), 'targetAttribute' => ['entity_id' => 'id'], 'on' => self::SCENARIO_JUNCTION],
			['entity_id', 'validateJunctionRelation', 'on' => self::SCENARIO_JUNCTION],
			['length', 'integer', 'when' => function($model) {return $model->lengthRequired();}],
			['precision', 'integer', 'when' => function($model) {return $model->precisionRequired();}],
			['scale', 'integer', 'when' => function($model) {return $model->scaleRequired();}],
		];
	}


	public function validateJunctionRelation($attribute, $params)
	{
		if ($this->relationship->isManyToMany() === false) 
			$this->addError($attribute, "Entities to share this attribute are not sharing a many_to_many relationship");
	}

{'fraction_non_alphanumeric': 0.2087078651685393, 'fraction_numerical': 0.0005617977528089888, 'mean_word_length': 5.928015564202335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, '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': '2601042', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1124, 'n_words': 262}