Extracts size, precision and scale information from column's DB type.
@param string $dbType the column's DB type
3695
protected function extractLimit($dbType)
	{
		if (strncmp($dbType, 'enum', 4)===0 && preg_match('/\(([\'"])(.*)\\1\)/',$dbType,$matches))
		{
			// explode by (single or double) quote and comma (ENUM values may contain commas)
			$values = explode($matches[1].','.$matches[1], $matches[2]);
			$size = 0;
			foreach($values as $value)
			{
				if(($n=strlen($value)) > $size)
					$size=$n;
			}
			$this->size = $this->precision = $size;
		}
		else
			parent::extractLimit($dbType);
	}
818416
public static function getSize($type)
    {
        if (array_key_exists($type, self::$formatLength)) {
            return self::$formatLength[$type];
        } else {
            return Pel::fmt('Unknown format: 0x%X', $type);
        }
    }
106701
private function getPhpType(string $doctrineType): ?string
    {
        switch ($doctrineType) {
            case DBALType::SMALLINT:
            case DBALType::INTEGER:
                return Type::BUILTIN_TYPE_INT;

            case DBALType::FLOAT:
                return Type::BUILTIN_TYPE_FLOAT;

            case DBALType::BIGINT:
            case DBALType::STRING:
            case DBALType::TEXT:
            case DBALType::GUID:
            case DBALType::DECIMAL:
                return Type::BUILTIN_TYPE_STRING;

            case DBALType::BOOLEAN:
                return Type::BUILTIN_TYPE_BOOL;

            case DBALType::BLOB:
            case 'binary':
                return Type::BUILTIN_TYPE_RESOURCE;

            case DBALType::OBJECT:
                return Type::BUILTIN_TYPE_OBJECT;
        }

        return null;
    }
699566
def _get_dbal_column_type(self, type_):
        
        type_ = type_.lower()

        if type_ == "enum":
            return "string"

        return super(PostgresSchemaGrammar, self)._get_dbal_column_type(type_)
508379
private function getPHPDocType($db_type, $relation = null)
    {
        switch ($db_type) {
            case 'datetime':
                return 'string|\Carbon\Carbon';
            case '1t1':
                return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.camel_case($relation->inputs[0]);
            case 'mt1':
                if (isset($relation->inputs[1])) {
                    $relationName = str_replace('_id', '', strtolower($relation->inputs[1]));
                } else {
                    $relationName = $relation->inputs[0];
                }

                return '\\'.$this->commandData->config->nsModel.'\\'.$relation->inputs[0].' '.camel_case($relationName);
            case '1tm':
            case 'mtm':
            case 'hmt':
                return '\Illuminate\Database\Eloquent\Collection'.' '.camel_case(str_plural($relation->inputs[0]));
            default:
                $fieldData = SwaggerGenerator::getFieldType($db_type);
                if (!empty($fieldData['fieldType'])) {
                    return $fieldData['fieldType'];
                }

                return $db_type;
        }
    }
760295
public function getPhinxType($sqlType)
    {
        switch ($sqlType) {
            case 'character varying':
            case 'varchar':
                return static::PHINX_TYPE_STRING;
            case 'character':
            case 'char':
                return static::PHINX_TYPE_CHAR;
            case 'text':
                return static::PHINX_TYPE_TEXT;
            case 'json':
                return static::PHINX_TYPE_JSON;
            case 'jsonb':
                return static::PHINX_TYPE_JSONB;
            case 'smallint':
                return static::PHINX_TYPE_SMALL_INTEGER;
            case 'int':
            case 'int4':
            case 'integer':
                return static::PHINX_TYPE_INTEGER;
            case 'decimal':
            case 'numeric':
                return static::PHINX_TYPE_DECIMAL;
            case 'bigint':
            case 'int8':
                return static::PHINX_TYPE_BIG_INTEGER;
            case 'real':
            case 'float4':
                return static::PHINX_TYPE_FLOAT;
            case 'double precision':
                return static::PHINX_TYPE_DOUBLE;
            case 'bytea':
                return static::PHINX_TYPE_BINARY;
            case 'interval':
                return static::PHINX_TYPE_INTERVAL;
            case 'time':
            case 'timetz':
            case 'time with time zone':
            case 'time without time zone':
                return static::PHINX_TYPE_TIME;
            case 'date':
                return static::PHINX_TYPE_DATE;
            case 'timestamp':
            case 'timestamptz':
            case 'timestamp with time zone':
            case 'timestamp without time zone':
                return static::PHINX_TYPE_DATETIME;
            case 'bool':
            case 'boolean':
                return static::PHINX_TYPE_BOOLEAN;
            case 'uuid':
                return static::PHINX_TYPE_UUID;
            case 'cidr':
                return static::PHINX_TYPE_CIDR;
            case 'inet':
                return static::PHINX_TYPE_INET;
            case 'macaddr':
                return static::PHINX_TYPE_MACADDR;
            default:
                throw new UnsupportedColumnTypeException('Column type "' . $sqlType . '" is not supported by Postgresql.');
        }
    }
473300
private function convertParameterType(int $type) : int
    {
        switch ($type) {
            case ParameterType::BINARY:
                return OCI_B_BIN;

            case ParameterType::LARGE_OBJECT:
                return OCI_B_BLOB;

            default:
                return SQLT_CHR;
        }
    }
1135753
public function getXMLDBFieldType($type) {

        $result = XMLDB_TYPE_INCORRECT;

        switch (strtolower($type)) {
            case 'int':
                $result = XMLDB_TYPE_INTEGER;
                break;
            case 'number':
                $result = XMLDB_TYPE_NUMBER;
                break;
            case 'float':
                $result = XMLDB_TYPE_FLOAT;
                break;
            case 'char':
                $result = XMLDB_TYPE_CHAR;
                break;
            case 'text':
                $result = XMLDB_TYPE_TEXT;
                break;
            case 'binary':
                $result = XMLDB_TYPE_BINARY;
                break;
            case 'datetime':
                $result = XMLDB_TYPE_DATETIME;
                break;
        }
        // Return the normalized XMLDB_TYPE
        return $result;
    }
256230
public function entityGetAttrType($demAttrType)
    {
        $result = MageType::COL_TEXT;
        $type = key($demAttrType);
        $typeData = reset($demAttrType);
        switch ($type) {
            case DemType::A_BINARY:
                $result = MageType::COL_BLOB;
                break;
            case DemType::A_BOOLEAN:
                $result = MageType::COL_BOOLEAN;
                break;
            case DemType::A_DATETIME:
                $result = MageType::COL_TIMESTAMP;
                break;
            case DemType::A_INTEGER:
                $result = MageType::COL_INTEGER;
                if (isset($typeData[Cfg::SUBTYPE])) {
                    if ($typeData[Cfg::SUBTYPE] == DemType::ATTRSUB_SMALL_INT) {
                        $result = MageType::COL_SMALLINT;
                    }
                }
                break;
            case DemType::A_NUMERIC:
                $result = MageType::COL_DECIMAL;
                break;
            case DemType::A_OPTION:
                $result = MageType::COL_TEXT;
                break;
            case DemType::A_TEXT:
                $result = MageType::COL_TEXT;
                break;
        }
        return $result;
    }
629509
private function generateNumberInput($column, $dbType)
    {
        $field = new GeneratorField();
        $field->name = $column->getName();
        $field->parseDBType($dbType.','.$column->getPrecision().','.$column->getScale());
        $field->htmlType = 'number';

        return $this->checkForPrimary($field);
    }
762188
public static function isTextType($mappingType)
    {
        return in_array($mappingType, [
            self::CHAR,
            self::VARCHAR,
            self::LONGVARCHAR,
            self::CLOB,
            self::DATE,
            self::TIME,
            self::TIMESTAMP,
            self::BU_DATE,
            self::BU_TIMESTAMP,
            self::JSON,
        ]);
    }
749804
public function getDoctrineTypeMapping($dbType)
    {
        if ($this->doctrineTypeMapping === null) {
            $this->initializeAllDoctrineTypeMappings();
        }

        $dbType = strtolower($dbType);

        if (! isset($this->doctrineTypeMapping[$dbType])) {
            throw new DBALException('Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.');
        }

        return $this->doctrineTypeMapping[$dbType];
    }
1361013
public function entityGetAttrSize($demAttrType)
    {
        $result = null;
        $type = key($demAttrType);
        $typeData = reset($demAttrType);
        switch ($type) {
            case DemType::A_BINARY:
                break;
            case DemType::A_BOOLEAN:
                break;
            case DemType::A_DATETIME:
                break;
            case DemType::A_INTEGER:
                $result = isset($typeData[Cfg::LENGTH]) ? $typeData[Cfg::LENGTH] : null;
                break;
            case DemType::A_NUMERIC:
                if (isset($typeData[Cfg::PRECISION])) {
                    /* we should have 2 elements in the result array*/
                    $result = [MageType::OPT_PRECISION => 10, MageType::OPT_SCALE => 0];
                    $result[MageType::OPT_PRECISION] = $typeData[Cfg::PRECISION];
                    if (isset($typeData[Cfg::SCALE])) {
                        $result[MageType::OPT_SCALE] = $typeData[Cfg::SCALE];
                    }
                }
                break;
            case DemType::A_OPTION:
                break;
            case DemType::A_TEXT:
                $result = isset($typeData[Cfg::LENGTH]) ? $typeData[Cfg::LENGTH] : null;
                break;
        }
        return $result;
    }
417922
public function getMeta($type, $dbms)
    {
        if (!isset($this->meta_types[strtoupper($type)])) {
            return $type;
        }
        $meta = $this->meta_types[strtoupper($type)];

        return isset($meta[$dbms]) ? $meta[$dbms] : $meta['default'];
    }
1353653
public function datatype($type)
	{
		static $types = array
		(
			// SQL-92
			'bit'                           => array('type' => 'string', 'exact' => true),
			'bit varying'                   => array('type' => 'string'),
			'char'                          => array('type' => 'string', 'exact' => true),
			'char varying'                  => array('type' => 'string'),
			'character'                     => array('type' => 'string', 'exact' => true),
			'character varying'             => array('type' => 'string'),
			'date'                          => array('type' => 'string'),
			'dec'                           => array('type' => 'float', 'exact' => true),
			'decimal'                       => array('type' => 'float', 'exact' => true),
			'double precision'              => array('type' => 'float'),
			'float'                         => array('type' => 'float'),
			'int'                           => array('type' => 'int', 'min' => '-2147483648', 'max' => '2147483647'),
			'integer'                       => array('type' => 'int', 'min' => '-2147483648', 'max' => '2147483647'),
			'interval'                      => array('type' => 'string'),
			'national char'                 => array('type' => 'string', 'exact' => true),
			'national char varying'         => array('type' => 'string'),
			'national character'            => array('type' => 'string', 'exact' => true),
			'national character varying'    => array('type' => 'string'),
			'nchar'                         => array('type' => 'string', 'exact' => true),
			'nchar varying'                 => array('type' => 'string'),
			'numeric'                       => array('type' => 'float', 'exact' => true),
			'real'                          => array('type' => 'float'),
			'smallint'                      => array('type' => 'int', 'min' => '-32768', 'max' => '32767'),
			'time'                          => array('type' => 'string'),
			'time with time zone'           => array('type' => 'string'),
			'timestamp'                     => array('type' => 'string'),
			'timestamp with time zone'      => array('type' => 'string'),
			'varchar'                       => array('type' => 'string'),

			// SQL:1999
			'binary large object'               => array('type' => 'string', 'binary' => true),
			'blob'                              => array('type' => 'string', 'binary' => true),
			'boolean'                           => array('type' => 'bool'),
			'char large object'                 => array('type' => 'string'),
			'character large object'            => array('type' => 'string'),
			'clob'                              => array('type' => 'string'),
			'national character large object'   => array('type' => 'string'),
			'nchar large object'                => array('type' => 'string'),
			'nclob'                             => array('type' => 'string'),
			'time without time zone'            => array('type' => 'string'),
			'timestamp without time zone'       => array('type' => 'string'),

			// SQL:2003
			'bigint'    => array('type' => 'int', 'min' => '-9223372036854775808', 'max' => '9223372036854775807'),

			// SQL:2008
			'binary'            => array('type' => 'string', 'binary' => true, 'exact' => true),
			'binary varying'    => array('type' => 'string', 'binary' => true),
			'varbinary'         => array('type' => 'string', 'binary' => true),
		);

		if (isset($types[$type]))
			return $types[$type];

		return array();
	}
862421
public function entityGetAttrSize($demAttrType)
    {
        $result = null;
        $type = key($demAttrType);
        $typeData = reset($demAttrType);
        switch ($type) {
            case DemType::ATTR_BINARY:
                break;
            case DemType::ATTR_BOOLEAN:
                break;
            case DemType::ATTR_DATETIME:
                break;
            case DemType::ATTR_INTEGER:
                $result = isset($typeData[Cfg::LENGTH]) ? $typeData[Cfg::LENGTH] : null;
                break;
            case DemType::ATTR_NUMERIC:
                if (isset($typeData[Cfg::PRECISION])) {
                    /* we should have 2 elements in the result array*/
                    $result = [MageType::OPT_PRECISION => 10, MageType::OPT_SCALE => 0];
                    $result[MageType::OPT_PRECISION] = $typeData[Cfg::PRECISION];
                    if (isset($typeData[Cfg::SCALE])) {
                        $result[MageType::OPT_SCALE] = $typeData[Cfg::SCALE];
                    }
                }
                break;
            case DemType::ATTR_OPTION:
                break;
            case DemType::ATTR_TEXT:
                $result = isset($typeData[Cfg::LENGTH]) ? $typeData[Cfg::LENGTH] : null;
                break;
        }
        return $result;
    }
375162
public static function normalizeDataType(string $type): string
    {
        $searchType = strtolower($type);

        return array_key_exists($searchType, self::$normalizations) ? self::$normalizations[$searchType] : $type;
    }