yiisoft/yii2 · error · NotSupportedException
Oracle does not support default value constraints.
Error message
Oracle does not support default value constraints.
What it means
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.
Source
Thrown at framework/db/oci/Schema.php:247
{
return $this->loadTableConstraints($tableName, 'uniques');
}
/**
* {@inheritdoc}
*/
protected function loadTableChecks($tableName)
{
return $this->loadTableConstraints($tableName, 'checks');
}
/**
* {@inheritdoc}
* @throws NotSupportedException if this method is called.
*/
protected function loadTableDefaultValues($tableName)
{
throw new NotSupportedException('Oracle does not support default value constraints.');
}
/**
* {@inheritdoc}
*/
public function releaseSavepoint($name)
{
// does nothing as Oracle does not support this
}
/**
* {@inheritdoc}
*/
public function quoteSimpleTableName($name)
{
return strpos($name, '"') !== false ? $name : '"' . $name . '"';
}
View on GitHub (pinned to 66f00d18a2)
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.
Example fix
// before
$defaults = $db->getTableDefaultValues('customer');
// after
$defaults = array_map(
fn($c) => $c->defaultValue,
$db->getTableSchema('customer', true)->columns
); Defensive patterns
Strategy: try-catch
Validate before calling
if ($db->driverName === 'oci') {
$defaults = array_map(fn($c) => $c->defaultValue, $db->getTableSchema($t, true)->columns);
} else {
$defaults = $db->getTableDefaultValues($t);
} Try / catch
try {
$defaults = $db->getTableDefaultValues($table);
} catch (\yii\db\NotSupportedException $e) {
$defaults = []; // named default constraints do not exist on this driver
} Prevention
- 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.
When it happens
Trigger: Calling $db->getTableDefaultValues('tbl') on an Oracle connection, typically from generic constraint-walking code that invokes every getTable* accessor regardless of driver.
Common situations: Schema-inspection tools or admin panels written against pgsql/mssql reused on Oracle; migration diff engines probing all constraint families.
Related errors
- Oracle does not support ON UPDATE clause.
- MySQL does not support default value constraints.
- Unknown table: $table
- There is no sequence associated with table: $table
- Can't reset sequence for composite primary key in table: $ta
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/f859181c98fc5a56.
Report an issue: GitHub.