{"record":{"id":"f859181c98fc5a56","repo":"yiisoft/yii2","slug":"oracle-does-not-support-default-value-constraints","errorCode":null,"errorMessage":"Oracle does not support default value constraints.","messagePattern":"Oracle does not support default value constraints\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"framework/db/oci/Schema.php","lineNumber":247,"sourceCode":"    {\n        return $this->loadTableConstraints($tableName, 'uniques');\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    protected function loadTableChecks($tableName)\n    {\n        return $this->loadTableConstraints($tableName, 'checks');\n    }\n\n    /**\n     * {@inheritdoc}\n     * @throws NotSupportedException if this method is called.\n     */\n    protected function loadTableDefaultValues($tableName)\n    {\n        throw new NotSupportedException('Oracle does not support default value constraints.');\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function releaseSavepoint($name)\n    {\n        // does nothing as Oracle does not support this\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function quoteSimpleTableName($name)\n    {\n        return strpos($name, '\"') !== false ? $name : '\"' . $name . '\"';\n    }\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/db/oci/Schema.php#L229-L265","documentation":"yii\\db\\oci\\Schema::loadTableDefaultValues() exists only to satisfy the base Schema contract for named DEFAULT constraints. Oracle applies defaults through column DDL, not named constraint objects, so introspecting them is impossible and the method unconditionally throws NotSupportedException.","triggerScenarios":"Calling $db->getTableDefaultValues('tbl') on an Oracle connection, typically from generic constraint-walking code that invokes every getTable* accessor regardless of driver.","commonSituations":"Schema-inspection tools or admin panels written against pgsql/mssql reused on Oracle; migration diff engines probing all constraint families.","solutions":["Do not call getTableDefaultValues() on Oracle - the concept does not map.","Read defaults from column metadata: getTableSchema($t)->columns[$name]->defaultValue.","In generic loops, branch on driver or catch NotSupportedException and continue."],"exampleFix":"// before\n$defaults = $db->getTableDefaultValues('customer');\n\n// after\n$defaults = array_map(\n    fn($c) => $c->defaultValue,\n    $db->getTableSchema('customer', true)->columns\n);","handlingStrategy":"try-catch","validationCode":"if ($db->driverName === 'oci') {\n    $defaults = array_map(fn($c) => $c->defaultValue, $db->getTableSchema($t, true)->columns);\n} else {\n    $defaults = $db->getTableDefaultValues($t);\n}","typeGuard":null,"tryCatchPattern":"try {\n    $defaults = $db->getTableDefaultValues($table);\n} catch (\\yii\\db\\NotSupportedException $e) {\n    $defaults = []; // named default constraints do not exist on this driver\n}","preventionTips":["Read defaults from TableSchema::columns instead of the constraint API on Oracle.","Branch constraint introspection on driver capabilities.","Document which constraint families each target driver supports."],"tags":["yii2","php","oracle","oci","database","default-constraint","not-supported"],"backgroundTag":"unsupported-driver-operation","analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}