{"record":{"id":"6b3933010fde8ec2","repo":"phalcon/cphalcon","slug":"unrecognized-mysql-data-type-at-column","errorCode":null,"errorMessage":"Unrecognized MySQL data type at column {}","messagePattern":"Unrecognized MySQL data type at column (.+?)","errorType":"exception","errorClass":"UnrecognizedDataType","httpStatus":null,"severity":"error","filePath":"phalcon/Db/Dialect/Mysql.zep","lineNumber":788,"sourceCode":"                break;\n\n            case Column::TYPE_MULTIPOLYGON:\n                if empty columnSql {\n                    let columnSql .= \"MULTIPOLYGON\";\n                }\n\n                break;\n\n            case Column::TYPE_GEOMETRYCOLLECTION:\n                if empty columnSql {\n                    let columnSql .= \"GEOMETRYCOLLECTION\";\n                }\n\n                break;\n\n            default:\n                if unlikely empty columnSql {\n                    throw new UnrecognizedDataType(\"MySQL\", column->getName());\n                }\n\n                let typeValues = column->getTypeValues();\n                if !empty typeValues {\n                    if typeof typeValues == \"array\" {\n                        var value, valueSql;\n\n                        let valueSql = \"\";\n\n                        for value in typeValues {\n                            let valueSql .= \"\\\"\" . addcslashes(value, \"\\\"\") . \"\\\", \";\n                        }\n\n                        let columnSql .= \"(\" . substr(valueSql, 0, -2) . \")\";\n                    } else {\n                        let columnSql .= \"(\\\"\" . addcslashes(typeValues, \"\\\"\") . \"\\\")\";\n                    }\n                }","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Db/Dialect/Mysql.zep#L770-L806","documentation":"Mysql dialect's column-to-SQL compiler throws UnrecognizedDataType when a Phalcon\\Db\\Column object's type constant falls through the big switch in the default branch and no explicit column SQL was set. That happens when the Column was constructed with an unknown/newer TYPE_* constant, or with type 0 / a raw integer that matches no case; the dialect refuses to guess a MySQL type for the column.","triggerScenarios":"new Column('meta', ['type' => 999]) or a type constant not handled by the Mysql dialect (e.g. a type introduced for another backend, or TYPE_BIGINTEGER/SERIAL variants handled only after a match); creating tables or adding columns via $adapter->createTable()/addColumn() with such a Column; deserializing Column definitions where 'type' failed to map.","commonSituations":"Sharing column definition constants across dialects in multi-backend code; copying TYPE_* constants between Phalcon versions where new constants exist but the dialect branch does not cover them; passing getColumn() results between adapters of different versions.","solutions":["Use a type constant supported by the MySQL dialect, e.g. Column::TYPE_VARCHAR, TYPE_INTEGER, TYPE_TEXT, TYPE_JSON — check the constants on the Phalcon\\Db\\Column class you run","Never pass raw integers; always use the named TYPE_* constants so a mismatch surfaces at compile time","Guard the constants you use with a small mapping array validated per adapter before calling createTable()/addColumn()"],"exampleFix":"// before\n$column = new Column('meta', ['type' => 999, 'size' => 10]);\n\n// after\n$column = new Column('meta', ['type' => Column::TYPE_VARCHAR, 'size' => 10]);","handlingStrategy":"type-guard","validationCode":"if (!in_array($column->getType(), $allowedMysqlTypes, true)) {\n    throw new InvalidArgumentException('Column type not supported by the MySQL dialect: ' . $column->getName());\n}","typeGuard":"// Guard at construction: only named constants, never raw integers.\nfunction mysqlColumn(string $name, array $definition): \\Phalcon\\Db\\Column\n{\n    if (!isset($definition['type']) || !is_int($definition['type'])\n        || $definition['type'] < 1) {\n        throw new InvalidArgumentException(\"Invalid type for column {$name}\");\n    }\n    return new \\Phalcon\\Db\\Column($name, $definition);\n}","tryCatchPattern":"try {\n    $connection->createTable($table, null, $definition);\n} catch (\\Phalcon\\Db\\Exceptions\\UnrecognizedDataType $e) {\n    throw new RuntimeException(\"DDL rejected for {$table}: \" . $e->getMessage(), 0, $e);\n}","preventionTips":["Always use named Column::TYPE_* constants from the Phalcon version you run","Keep per-adapter whitelists of supported types in shared schema code","Test migrations on the same adapter and Phalcon version as production"],"tags":["phalcon","mysql","ddl","column-type","create-table"],"backgroundTag":"unsupported-column-type","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}