From 703ba51fabdf793e57e08860a56b0741201f519d Mon Sep 17 00:00:00 2001 From: doctrine Date: Wed, 5 Jul 2006 18:59:46 +0000 Subject: [PATCH] Sqlite datadict: composite primary key support --- Doctrine/DataDict.php | 3 ++- Doctrine/Locking/Manager/Pessimistic.php | 2 +- Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Doctrine/DataDict.php b/Doctrine/DataDict.php index 95db8b3f4..df6dff607 100644 --- a/Doctrine/DataDict.php +++ b/Doctrine/DataDict.php @@ -40,7 +40,8 @@ class Doctrine_DataDict { try { $this->dbh->query($sql); } catch(PDOException $e) { - $return = false; + + $return = $e; } } diff --git a/Doctrine/Locking/Manager/Pessimistic.php b/Doctrine/Locking/Manager/Pessimistic.php index 22b43185a..fca920a25 100644 --- a/Doctrine/Locking/Manager/Pessimistic.php +++ b/Doctrine/Locking/Manager/Pessimistic.php @@ -237,4 +237,4 @@ class Doctrine_Locking_Manager_Pessimistic } -?> \ No newline at end of file +?> diff --git a/Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php b/Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php index b76af462c..3bb3621b0 100644 --- a/Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php +++ b/Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php @@ -56,6 +56,7 @@ class ADODB2_sqlite extends ADODB_DataDict { if ($funsigned) $suffix .= ' UNSIGNED'; if ($fnotnull) $suffix .= ' NOT NULL'; if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fautoinc) $suffix .= ' PRIMARY KEY AUTOINCREMENT'; if ($fconstraint) $suffix .= ' '.$fconstraint; return $suffix; @@ -77,12 +78,12 @@ class ADODB2_sqlite extends ADODB_DataDict { } $s = "CREATE TABLE $tabname (\n"; $s .= implode(",\n", $lines); - /** - if (sizeof($pkey)>0) { + + if (sizeof($pkey)>0 && ! $this->autoIncrement) { $s .= ",\n PRIMARY KEY ("; $s .= implode(", ",$pkey).")"; } - */ + if (isset($tableoptions['CONSTRAINTS'])) $s .= "\n".$tableoptions['CONSTRAINTS'];