{"record":{"id":"9c8aba704f505518","repo":"yiisoft/yii2","slug":"cubrid-does-not-support-default-value-constraints","errorCode":null,"errorMessage":"CUBRID does not support default value constraints.","messagePattern":"CUBRID does not support default value constraints\\.","errorType":"exception","errorClass":"yii\\base\\NotSupportedException","httpStatus":null,"severity":"error","filePath":"framework/db/cubrid/Schema.php","lineNumber":241,"sourceCode":"        return $this->loadTableConstraints($tableName, 'uniques');\n    }\n\n    /**\n     * {@inheritdoc}\n     * @throws NotSupportedException if this method is called.\n     */\n    protected function loadTableChecks($tableName)\n    {\n        throw new NotSupportedException('CUBRID does not support check constraints.');\n    }\n\n    /**\n     * {@inheritdoc}\n     * @throws NotSupportedException if this method is called.\n     */\n    protected function loadTableDefaultValues($tableName)\n    {\n        throw new NotSupportedException('CUBRID does not support default value constraints.');\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function releaseSavepoint($name)\n    {\n        // does nothing as cubrid does not support this\n    }\n\n    /**\n     * Creates a query builder for the CUBRID database.\n     * @return QueryBuilder query builder instance\n     */\n    public function createQueryBuilder()\n    {\n        return Yii::createObject(QueryBuilder::className(), [$this->db]);\n    }","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/db/cubrid/Schema.php#L223-L259","documentation":"yii\\db\\cubrid\\Schema::loadTableDefaultValues() (framework/db/cubrid/Schema.php:241) is the loader behind Schema::getTableDefaultValues() and throws NotSupportedException unconditionally because Yii's CUBRID driver does not read default-value constraints from the catalog. Like loadTableChecks() above it, this fires from schema introspection rather than from DDL you wrote yourself.","triggerScenarios":"$db->schema->getTableDefaultValues('product'); tooling iterating all constraint types (checks/uniques/defaults); schema diffing or ER-diagram generation against CUBRID.","commonSituations":"Cross-DBMS introspection utilities; model/code generators enumerating constraints; QA tooling that validates schema expectations on every supported driver.","solutions":["Skip default-value introspection when the driver is cubrid","Catch yii\\db\\NotSupportedException and degrade to an empty list","Read defaults from getTableSchema()->columns[x]->defaultValue instead, which the CUBRID driver does support"],"exampleFix":"// before\n$defaults = $db->schema->getTableDefaultValues('product'); // throws on CUBRID\n\n// after\ntry {\n    $defaults = $db->schema->getTableDefaultValues('product');\n} catch (\\yii\\db\\NotSupportedException $e) {\n    $defaults = []; // not supported by the CUBRID driver\n}","handlingStrategy":"try-catch","validationCode":"$defaults = [];\nif ($db->driverName !== 'cubrid') {\n    $defaults = $db->schema->getTableDefaultValues($tableName);\n} else {\n    // column-level defaults are still available:\n    foreach ($db->getTableSchema($tableName)->columns as $name => $column) {\n        $defaults[$name] = $column->defaultValue;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $defaults = $db->schema->getTableDefaultValues($tableName);\n} catch (\\yii\\db\\NotSupportedException $e) {\n    $defaults = []; // fall back to TableSchema->columns[x]->defaultValue\n}","preventionTips":["Use TableSchema->columns[x]->defaultValue for portable default-value introspection","Skip constraint-type loaders the driver declares unsupported","Feature-detect per driver in shared introspection code"],"tags":["yii2","cubrid","database","schema","introspection","default-value","not-supported"],"backgroundTag":"unsupported-database-feature","analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}