<commit_before><?php

App::uses('AppModel', 'Model');

class ObjectTemplateElement extends AppModel
{
    public $actsAs = array(
            'Containable'
    );

    public $belongsTo = array(
    );

    public $validate = array(
    );

    public function afterFind($results, $primary = false)
    {
        foreach ($results as $k => $result) {
            if (isset($results[$k]['ObjectTemplateElement']['categories'])) {
                $results[$k]['ObjectTemplateElement']['categories'] = json_decode($results[$k]['ObjectTemplateElement']['categories'], true);
            }
            if (isset($results[$k]['ObjectTemplateElement']['values_list'])) {
                $results[$k]['ObjectTemplateElement']['values_list'] = json_decode($results[$k]['ObjectTemplateElement']['values_list'], true);
            }
            if (isset($results[$k]['ObjectTemplateElement']['sane_default'])) {
                $results[$k]['ObjectTemplateElement']['sane_default'] = json_decode($results[$k]['ObjectTemplateElement']['sane_default'], true);
            }
        }
        return $results;
    }

    public function beforeSave($options = array())
    {
        if (empty($this->data['ObjectTemplateElement']['description'])) {
            $this->data['ObjectTemplateElement']['description'] = '';
        }
        $json_fields = array('categories', 'values_list', 'sane_default');
        foreach ($json_fields as $field) {
            $this->data['ObjectTemplateElement'][$field] = empty($this->data['ObjectTemplateElement'][$field]) ? '[]' : json_encode($this->data['ObjectTemplateElement'][$field]);
        }
        return true;
    }


    public function getAllAvailableTypes() {
        $temp = $this->find('all', array(
            'recursive' => -1,
            'fields' => array('object_relation as type', 'description AS desc', 'categories'),
            'group' => 'type'
        ));
        $res = array();
        foreach ($temp as $type) {
            $res[$type['ObjectTemplateElement']['type']] = array(
                'desc' => $type['ObjectTemplateElement']['desc'],
                'category' => $type['ObjectTemplateElement']['categories']
            );
        }
        return $res;
    }
}<commit_msg>fix: [decaying:tool] Support strict sql mode while fetching available Object type<commit_after><?php

App::uses('AppModel', 'Model');

class ObjectTemplateElement extends AppModel
{
    public $actsAs = array(
            'Containable'
    );

    public $belongsTo = array(
    );

    public $validate = array(
    );

    public function afterFind($results, $primary = false)
    {
        foreach ($results as $k => $result) {
            if (isset($results[$k]['ObjectTemplateElement']['categories'])) {
                $results[$k]['ObjectTemplateElement']['categories'] = json_decode($results[$k]['ObjectTemplateElement']['categories'], true);
            }
            if (isset($results[$k]['ObjectTemplateElement']['values_list'])) {
                $results[$k]['ObjectTemplateElement']['values_list'] = json_decode($results[$k]['ObjectTemplateElement']['values_list'], true);
            }
            if (isset($results[$k]['ObjectTemplateElement']['sane_default'])) {
                $results[$k]['ObjectTemplateElement']['sane_default'] = json_decode($results[$k]['ObjectTemplateElement']['sane_default'], true);
            }
        }
        return $results;
    }

    public function beforeSave($options = array())
    {
        if (empty($this->data['ObjectTemplateElement']['description'])) {
            $this->data['ObjectTemplateElement']['description'] = '';
        }
        $json_fields = array('categories', 'values_list', 'sane_default');
        foreach ($json_fields as $field) {
            $this->data['ObjectTemplateElement'][$field] = empty($this->data['ObjectTemplateElement'][$field]) ? '[]' : json_encode($this->data['ObjectTemplateElement'][$field]);
        }
        return true;
    }


    public function getAllAvailableTypes() {
        $temp = $this->find('all', array(
            'recursive' => -1,
            'fields' => array('object_relation as type', 'description AS desc', 'categories'),
            'group' => array('object_relation', 'description', 'categories')
        ));
        $res = array();
        foreach ($temp as $type) {
            $res[$type['ObjectTemplateElement']['type']] = array(
                'desc' => $type['ObjectTemplateElement']['desc'],
                'category' => $type['ObjectTemplateElement']['categories']
            );
        }
        return $res;
    }
}
{'fraction_non_alphanumeric': 0.17520156896927436, 'fraction_numerical': 0.00043582479843103073, 'mean_word_length': 2.8799661876584954, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6796595', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1173, 'n_words': 204}