{"record":{"id":"cd50dfa9279b0db1","repo":"phalcon/cphalcon","slug":"column-type-does-not-support-scale-parameter","errorCode":null,"errorMessage":"Column type does not support scale parameter","messagePattern":"Column type does not support scale parameter","errorType":"exception","errorClass":"ColumnTypeRejectsScale","httpStatus":null,"severity":"error","filePath":"phalcon/Db/Column.zep","lineNumber":643,"sourceCode":"\n        /**\n         * Check if the column has a decimal scale\n         */\n        if fetch scale, definition[\"scale\"] {\n            switch type {\n                case self::TYPE_BIGINTEGER:\n                case self::TYPE_DECIMAL:\n                case self::TYPE_DOUBLE:\n                case self::TYPE_FLOAT:\n                case self::TYPE_INTEGER:\n                case self::TYPE_MEDIUMINTEGER:\n                case self::TYPE_SMALLINTEGER:\n                case self::TYPE_TINYINTEGER:\n                    let this->scale = scale;\n                    break;\n\n                default:\n                    throw new ColumnTypeRejectsScale();\n            }\n        }\n\n        /**\n         * Check if the column is default value\n         */\n        if fetch defaultValue, definition[\"default\"] {\n            let this->defaultValue = defaultValue;\n        }\n\n        /**\n         * Check if the field is unsigned (only MySQL)\n         */\n        if fetch dunsigned, definition[\"unsigned\"] {\n            let this->unsigned = dunsigned;\n        }\n\n        /**","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Db/Column.zep#L625-L661","documentation":"Phalcon\\Db\\Column only accepts a 'scale' (decimal digits) definition for numeric types: BIGINTEGER, DECIMAL, DOUBLE, FLOAT, INTEGER, MEDIUMINTEGER, SMALLINTEGER and TINYINTEGER. Combining any other type with 'scale' throws ColumnTypeRejectsScale, because e.g. a VARCHAR or DATE with a scale is meaningless SQL.","triggerScenarios":"new Column('name', ['type' => Column::TYPE_VARCHAR, 'scale' => 2]); a generic definition template that includes scale applied to every column; describeColumns round-trips where scale was carried onto non-numeric columns.","commonSituations":"Reusable column blueprints applied to all fields; migrations generated by cloning a DECIMAL column definition; config formats that always emit precision/scale pairs; copy-paste from a numeric column.","solutions":["Remove 'scale' from non-numeric column definitions.","For character lengths use 'size' (e.g. VARCHAR(255)), never 'scale'.","When generating definitions programmatically, emit 'scale' only for the numeric TYPE_* set."],"exampleFix":"// before\n$column = new Column('title', [\n    'type'  => Column::TYPE_VARCHAR,\n    'size'  => 255,\n    'scale' => 0, // throws ColumnTypeRejectsScale - VARCHAR has no scale\n]);\n\n// after\n$column = new Column('title', [\n    'type' => Column::TYPE_VARCHAR,\n    'size' => 255,\n]);","handlingStrategy":"type-guard","validationCode":"$scaleTypes = [\n    Column::TYPE_BIGINTEGER, Column::TYPE_DECIMAL, Column::TYPE_DOUBLE,\n    Column::TYPE_FLOAT, Column::TYPE_INTEGER, Column::TYPE_MEDIUMINTEGER,\n    Column::TYPE_SMALLINTEGER, Column::TYPE_TINYINTEGER,\n];\nif (isset($definition['scale']) && !in_array($definition['type'], $scaleTypes, true)) {\n    unset($definition['scale']); // or throw your own error\n}\n$column = new Column('title', $definition);","typeGuard":"function typeSupportsScale(int $type): bool\n{\n    return in_array($type, [\n        Column::TYPE_BIGINTEGER, Column::TYPE_DECIMAL, Column::TYPE_DOUBLE,\n        Column::TYPE_FLOAT, Column::TYPE_INTEGER, Column::TYPE_MEDIUMINTEGER,\n        Column::TYPE_SMALLINTEGER, Column::TYPE_TINYINTEGER,\n    ], true);\n}","tryCatchPattern":null,"preventionTips":["Use 'size' for character lengths and 'scale' only for numeric types.","Do not copy numeric column templates onto non-numeric columns.","Assert scale usage against the allowed type set in schema-definition unit tests."],"tags":["column","type-mismatch","schema-definition","phalcon-db"],"backgroundTag":"column-type-not-supported","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}