source/Core/Database/Adapter/Doctrine/Database.php
protected function getColumnMaxLengthAndScale(array $column, $assignedType)
    {
        /** @var int $maxLength The max length of a field. For floating point type or fixed point type fields the precision of the field */
        $maxLength = -1;
        /** @var int $scale The scale of floating point type or fixed point type fields */
        $scale = -1;

        /** @var string $mySqlType E.g. "CHAR(4)" or "DECIMAL(5,2)" or "tinyint(1) unsigned" */
        $mySqlType = $this->getMetaColumnValueByKey($column, 'Type');
        /** Get the maximum display width for the type */

        /** Match Precision an scale E.g DECIMAL(5,2) */
        if (preg_match("/^(.+)\((\d+),(\d+)/", $mySqlType, $matches)) {
            if (is_numeric($matches[2])) {
                $maxLength = $matches[2];
            }
            if (is_numeric($matches[3])) {
                $scale = $matches[3];
            }
            /** Match max length E.g CHAR(4) */
        } elseif (preg_match("/^(.+)\((\d+)/", $mySqlType, $matches)) {
            if (is_numeric($matches[2])) {
                $maxLength = $matches[2];
            }
            /**
             * Match List type E.g. SET('A', 'B', 'CDE)
             * In this case the length will be the string length of the longest element
             */
        } elseif (preg_match("/^(enum|set)\((.*)\)$/i", strtolower($mySqlType), $matches)) {
            if ($matches[2]) {
                $pieces = explode(",", $matches[2]);
                /** The array values contain 2 quotes, so we have to subtract 2 from the strlen */
                $maxLength = max(array_map("strlen", $pieces)) - 2;
                if ($maxLength <= 0) {
                    $maxLength = 1;
                }
            }
        }

        /** Numeric types, which may have a maximum length */
        $integerTypes = ['INTEGER', 'INT', 'SMALLINT', 'TINYINT', 'MEDIUMINT', 'BIGINT'];
        $fixedPointTypes = ['DECIMAL', 'NUMERIC'];
        $floatingPointTypes = ['FLOAT', 'DOUBLE'];

        /** Text types, which may have a maximum length */
        $textTypes = ['CHAR', 'VARCHAR'];

        /** Date types, which may have a maximum length */
        $dateTypes = ['YEAR'];

        $assignedType = strtoupper($assignedType);
        if ((
                in_array($assignedType, $integerTypes) ||
                in_array($assignedType, $fixedPointTypes) ||
                in_array($assignedType, $floatingPointTypes) ||
                in_array($assignedType, $textTypes) ||
                in_array($assignedType, $dateTypes)
            ) && -1 == $maxLength
        ) {
            /**
             * @todo: If the assigned type is one of the following and maxLength is -1, then, if applicable the default max length ot that type should be assigned.
             */
        }

        return [(int) $maxLength, (int) $scale];
    }
protected function getColumnMaxLengthAndScale(array $column, $assignedType)
    {
        /** @var int $maxLength The max length of a field. For floating point type or fixed point type fields the precision of the field */
        $maxLength = -1;
        /** @var int $scale The scale of floating point type or fixed point type fields */
        $scale = -1;

        /** @var string $mySqlType E.g. "CHAR(4)" or "DECIMAL(5,2)" or "tinyint(1) unsigned" */
        $mySqlType = $this->getMetaColumnValueByKey($column, 'Type');
        /** Get the maximum display width for the type */

        /** Match Precision an scale E.g DECIMAL(5,2) */
        if (preg_match("/^(.+)\((\d+),(\d+)/", $mySqlType, $matches)) {
            if (is_numeric($matches[2])) {
                $maxLength = $matches[2];
            }
            if (is_numeric($matches[3])) {
                $scale = $matches[3];
            }
            /** Match max length E.g CHAR(4) */
        } elseif (preg_match("/^(.+)\((\d+)/", $mySqlType, $matches)) {
            if (is_numeric($matches[2])) {
                $maxLength = $matches[2];
            }
            /**
             * Match List type E.g. SET('A', 'B', 'CDE)
             * In this case the length will be the string length of the longest element
             */
        } elseif (preg_match("/^(enum|set)\((.*)\)$/i", strtolower($mySqlType), $matches)) {
            if ($matches[2]) {
                $pieces = explode(",", $matches[2]);
                /** The array values contain 2 quotes, so we have to subtract 2 from the strlen */
                $maxLength = max(array_map("strlen", $pieces)) - 2;
                if ($maxLength <= 0) {
                    $maxLength = 1;
                }
            }
        }

        /** Numeric types, which may have a maximum length */
        $integerTypes = ['INTEGER', 'INT', 'SMALLINT', 'TINYINT', 'MEDIUMINT', 'BIGINT'];
        $fixedPointTypes = ['DECIMAL', 'NUMERIC'];
        $floatingPointTypes = ['FLOAT', 'DOUBLE'];

        /** Text types, which may have a maximum length */
        $textTypes = ['CHAR', 'VARCHAR'];

        /** Date types, which may have a maximum length */
        $dateTypes = ['YEAR'];

        $assignedType = strtoupper($assignedType);
        if ((
                in_array($assignedType, $integerTypes) ||
                in_array($assignedType, $fixedPointTypes) ||
                in_array($assignedType, $floatingPointTypes) ||
                in_array($assignedType, $textTypes) ||
                in_array($assignedType, $dateTypes)
            ) && -1 == $maxLength
        ) {
            /**
             * @todo: If the assigned type is one of the following and maxLength is -1, then, if applicable the default max length ot that type should be assigned.
             */
        }

        return [(int) $maxLength, (int) $scale];
    }
protected function getColumnMaxLengthAndScale ( array $ column , $ assignedType ) { /** @var int $maxLength The max length of a field. For floating point type or fixed point type fields the precision of the field */ $ maxLength = - 1 ; /** @var int $scale The scale of floating point type or fixed point type fields */ $ scale = - 1 ; /** @var string $mySqlType E.g. "CHAR(4)" or "DECIMAL(5,2)" or "tinyint(1) unsigned" */ $ mySqlType = $ this -> getMetaColumnValueByKey ( $ column , 'Type' ) ; /** Get the maximum display width for the type */ /** Match Precision an scale E.g DECIMAL(5,2) */ if ( preg_match ( "/^(.+)\((\d+),(\d+)/" , $ mySqlType , $ matches ) ) { if ( is_numeric ( $ matches [ 2 ] ) ) { $ maxLength = $ matches [ 2 ] ; } if ( is_numeric ( $ matches [ 3 ] ) ) { $ scale = $ matches [ 3 ] ; } /** Match max length E.g CHAR(4) */ } elseif ( preg_match ( "/^(.+)\((\d+)/" , $ mySqlType , $ matches ) ) { if ( is_numeric ( $ matches [ 2 ] ) ) { $ maxLength = $ matches [ 2 ] ; } /**
             * Match List type E.g. SET('A', 'B', 'CDE)
             * In this case the length will be the string length of the longest element
             */ } elseif ( preg_match ( "/^(enum|set)\((.*)\)$/i" , strtolower ( $ mySqlType ) , $ matches ) ) { if ( $ matches [ 2 ] ) { $ pieces = explode ( "," , $ matches [ 2 ] ) ; /** The array values contain 2 quotes, so we have to subtract 2 from the strlen */ $ maxLength = max ( array_map ( "strlen" , $ pieces ) ) - 2 ; if ( $ maxLength <= 0 ) { $ maxLength = 1 ; } } } /** Numeric types, which may have a maximum length */ $ integerTypes = [ 'INTEGER' , 'INT' , 'SMALLINT' , 'TINYINT' , 'MEDIUMINT' , 'BIGINT' ] ; $ fixedPointTypes = [ 'DECIMAL' , 'NUMERIC' ] ; $ floatingPointTypes = [ 'FLOAT' , 'DOUBLE' ] ; /** Text types, which may have a maximum length */ $ textTypes = [ 'CHAR' , 'VARCHAR' ] ; /** Date types, which may have a maximum length */ $ dateTypes = [ 'YEAR' ] ; $ assignedType = strtoupper ( $ assignedType ) ; if ( ( in_array ( $ assignedType , $ integerTypes ) || in_array ( $ assignedType , $ fixedPointTypes ) || in_array ( $ assignedType , $ floatingPointTypes ) || in_array ( $ assignedType , $ textTypes ) || in_array ( $ assignedType , $ dateTypes ) ) && - 1 == $ maxLength ) { /**
             * @todo: If the assigned type is one of the following and maxLength is -1, then, if applicable the default max length ot that type should be assigned.
             */ } return [ ( int ) $ maxLength , ( int ) $ scale ] ; }
Get the maximal length of a given column of a given type.

@param array  $column       The meta column for which the may length has to be found.
@param string $assignedType The type of the column.

@return int[] The maximal length and the scale (in case of DECIMAL type).
Both variables are -1 in case of no value can be found.
Get the maximal length of a given column of a given type .