{"record":{"id":"736286e3628a1924","repo":"phalcon/cphalcon","slug":"unrecognized-postgresql-data-type-at-column","errorCode":null,"errorMessage":"Unrecognized PostgreSQL data type at column {}","messagePattern":"Unrecognized PostgreSQL data type at column (.+?)","errorType":"exception","errorClass":"UnrecognizedDataType","httpStatus":null,"severity":"error","filePath":"phalcon/Db/Dialect/Postgresql.zep","lineNumber":786,"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(\"PostgreSQL\", column->getName());\n                }\n\n                let typeValues = column->getTypeValues();\n                if !empty typeValues {\n                    if typeof typeValues == \"array\" {\n                        var value;\n                        string 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                    }","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Db/Dialect/Postgresql.zep#L768-L804","documentation":"The PostgreSQL dialect's column compiler throws UnrecognizedDataType (message names PostgreSQL) when a Column's type constant reaches the default branch of the type switch with no column SQL produced. The Column was built with a type unknown to this dialect — a raw integer, a constant from a different Phalcon version, or one not applicable to PostgreSQL — so the dialect refuses to invent a PostgreSQL type.","triggerScenarios":"new Column('data', ['type' => 999]) in a Postgres createTable()/addColumn() call; sharing column-definition factories across MySQL and PostgreSQL where one side uses constants the other dialect never matches; Column objects unserialized with a stale type value.","commonSituations":"Multi-database model metadata reused across adapters; version skew between the Phalcon version that defined new TYPE_* constants and the dialect implementation; hand-written migration arrays with numeric types.","solutions":["Use PostgreSQL-supported constants, e.g. Column::TYPE_SERIAL, TYPE_JSONB/TYPE_JSON, TYPE_VARCHAR, TYPE_TIMESTAMP — verify against your Phalcon\\Db\\Column","Reference constants by name, never by integer, in migrations","Per-adapter column-type mapping tables in shared schema code, validated before DDL generation"],"exampleFix":"// before\n$column = new Column('data', ['type' => 999]);\n\n// after\n$column = new Column('data', ['type' => Column::TYPE_JSONB]);","handlingStrategy":"type-guard","validationCode":"if (!in_array($column->getType(), $allowedPostgresTypes, true)) {\n    throw new InvalidArgumentException('Column type not supported by the PostgreSQL dialect: ' . $column->getName());\n}","typeGuard":"function pgColumn(string $name, int $type, array $definition = []): \\Phalcon\\Db\\Column\n{\n    // Only accept named constants; reject 0/negative/unknown integers early.\n    if ($type < 1 || !in_array($type, $knownTypeConstants, true)) {\n        throw new InvalidArgumentException(\"Unknown column type for {$name}\");\n    }\n    return new \\Phalcon\\Db\\Column($name, $definition + ['type' => $type]);\n}","tryCatchPattern":"try {\n    $connection->createTable($table, 'public', $definition);\n} catch (\\Phalcon\\Db\\Exceptions\\UnrecognizedDataType $e) {\n    throw new RuntimeException(\"DDL rejected for {$table}: \" . $e->getMessage(), 0, $e);\n}","preventionTips":["Use named TYPE_* constants of the Phalcon version in production, never integers","Keep shared column factories per adapter instead of one global mapping","Pin and test the same Phalcon version across all environments"],"tags":["phalcon","postgresql","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"}