<commit_before><?php

class Octopus_Model_Field_Numeric extends Octopus_Model_Field {

    public function accessValue($model, $saving = false) {

        $value = parent::accessValue($model, $saving);

        // regexs to truncate decimal fields
        if (!$saving && $decimal_places = $this->getOption('decimal_places')) {
            $value = preg_replace('/^(.*\.\d{' . $decimal_places . '})(\d*)/', '$1', $value);

            // overflow the precision
            if ($precision = $this->getOption('precision')) {
                $value = min($value * pow(10, $decimal_places), doubleval(str_repeat('9', $precision))) / pow(10, $decimal_places);
            }

        }

        return $value;

    }

    public function migrate($schema, $table) {

        if ($decimalPlaces = $this->getOption('decimal_places')) {
            $precision = $this->getOption('precision', 60);
            $table->newDecimal($this->getFieldName(), $precision, $decimalPlaces);
        } else {
            $table->newBigInt($this->getFieldName());
        }

    }

    public function save($model, $sqlQuery) {
        $value = $this->accessValue($model, true);
        $value = preg_replace('/[^\d\.]/', '', $value);
        $sqlQuery->set($this->getFieldName(), $value);
    }
<commit_msg>- Allow saving negative numeric values :-)<commit_after><?php

class Octopus_Model_Field_Numeric extends Octopus_Model_Field {

    public function accessValue($model, $saving = false) {

        $value = parent::accessValue($model, $saving);

        // regexs to truncate decimal fields
        if (!$saving && $decimal_places = $this->getOption('decimal_places')) {
            $value = preg_replace('/^(.*\.\d{' . $decimal_places . '})(\d*)/', '$1', $value);

            // overflow the precision
            if ($precision = $this->getOption('precision')) {
                $value = min($value * pow(10, $decimal_places), doubleval(str_repeat('9', $precision))) / pow(10, $decimal_places);
            }

        }

        return $value;

    }

    public function migrate($schema, $table) {

        if ($decimalPlaces = $this->getOption('decimal_places')) {
            $precision = $this->getOption('precision', 60);
            $table->newDecimal($this->getFieldName(), $precision, $decimalPlaces);
        } else {
            $table->newBigInt($this->getFieldName());
        }

    }

    public function save($model, $sqlQuery) {
        $value = $this->accessValue($model, true);
        $value = preg_replace('/[^\d\.-]/', '', $value);
        $sqlQuery->set($this->getFieldName(), $value);
    }

{'fraction_non_alphanumeric': 0.1773076923076923, 'fraction_numerical': 0.006153846153846154, 'mean_word_length': 2.5826446280991737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '355317', 'n_tokens_mistral': 823, 'n_tokens_neox': 753, 'n_words': 148}