1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-10 08:04:32 +02:00

SQLite & SQLite3: improved primary key detection for ROWID

This commit is contained in:
David Grudl
2010-08-03 21:28:06 +02:00
parent f3c2c27818
commit 6b166afffb
2 changed files with 26 additions and 0 deletions

View File

@@ -478,6 +478,19 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector
} }
$res[$index]['primary'] = (bool) $primary; $res[$index]['primary'] = (bool) $primary;
} }
if (!$res) { // @see http://www.sqlite.org/lang_createtable.html#rowid
foreach ($columns as $column) {
if ($column['vendor']['pk']) {
$res[] = array(
'name' => 'ROWID',
'unique' => TRUE,
'primary' => TRUE,
'columns' => array($column['name']),
);
break;
}
}
}
return array_values($res); return array_values($res);
} }

View File

@@ -464,6 +464,19 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflecto
} }
$res[$index]['primary'] = (bool) $primary; $res[$index]['primary'] = (bool) $primary;
} }
if (!$res) { // @see http://www.sqlite.org/lang_createtable.html#rowid
foreach ($columns as $column) {
if ($column['vendor']['pk']) {
$res[] = array(
'name' => 'ROWID',
'unique' => TRUE,
'primary' => TRUE,
'columns' => array($column['name']),
);
break;
}
}
}
return array_values($res); return array_values($res);
} }