From a4f4d14eb98a3f9ff4f1c45946857d475456d2eb Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 11 Mar 2011 16:37:22 +1300 Subject: [PATCH 1/3] API CHANGE Renamed transactions methods from endTransaction() to transactionEnd(), startTransaction() to transactionStart() to comply with new sapphire trunk API --- code/SQLite3Database.php | 56 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/code/SQLite3Database.php b/code/SQLite3Database.php index bcf9a58..7bab4e1 100644 --- a/code/SQLite3Database.php +++ b/code/SQLite3Database.php @@ -953,17 +953,24 @@ class SQLite3Database extends SS_Database { return true; elseif(isset($extensions['clustering'])) return true; - else - return false; - } - - /* - * Start a prepared transaction - */ - public function startTransaction($transaction_mode=false, $session_characteristics=false){ - DB::query('BEGIN'); - } - + else + return false; + } + + /** + * @deprecated 1.2 use transactionStart() (method required for 2.4.x) + */ + public function startTransaction($transaction_mode=false, $session_characteristics=false){ + $this->transactionStart($transaction_mode, $session_characteristics); + } + + /* + * Start a prepared transaction + */ + public function transactionStart($transaction_mode=false, $session_characteristics=false){ + DB::query('BEGIN'); + } + /* * Create a savepoint that you can jump back to if you encounter problems */ @@ -982,16 +989,23 @@ class SQLite3Database extends SS_Database { DB::query("ROLLBACK TO $savepoint;"); } else { DB::query('ROLLBACK;'); - } - } - - /* - * Commit everything inside this transaction so far - */ - public function endTransaction(){ - DB::query('COMMIT;'); - } - + } + } + + /** + * @deprecated 1.2 use transactionEnd() (method required for 2.4.x) + */ + public function endTransaction(){ + $this->transactionEnd(); + } + + /* + * Commit everything inside this transaction so far + */ + public function transactionEnd(){ + DB::query('COMMIT;'); + } + /** * Convert a SQLQuery object into a SQL statement */ From b65482f8d118af595524cf09d268e16cb9e51539 Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Tue, 1 Mar 2011 12:05:28 +0100 Subject: [PATCH 2/3] Added missing method clear_cached_fieldlist existing in tests and at least in MySQLDatabase --- code/SQLite3Database.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/code/SQLite3Database.php b/code/SQLite3Database.php index 7bab4e1..48977cf 100644 --- a/code/SQLite3Database.php +++ b/code/SQLite3Database.php @@ -1006,10 +1006,22 @@ class SQLite3Database extends SS_Database { DB::query('COMMIT;'); } - /** - * Convert a SQLQuery object into a SQL statement - */ - public function sqlQueryToString(SQLQuery $sqlQuery) { + /** + * + * This is a stub function. Postgres caches the fieldlist results. + * + * @param string $tableName + * + * @return boolean + */ + function clear_cached_fieldlist($tableName=false){ + return true; + } + + /** + * Convert a SQLQuery object into a SQL statement + */ + public function sqlQueryToString(SQLQuery $sqlQuery) { if (!$sqlQuery->from) return ''; $distinct = $sqlQuery->distinct ? "DISTINCT " : ""; if($sqlQuery->delete) { From 0dfbf538b60d3a5d1ec11963db480c239faacc75 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 6 Apr 2011 22:39:57 +1200 Subject: [PATCH 3/3] BUGFIX Fixed supportsTransactions() to use version_compare() so it doesn't break on non-scalar versions like '3.7.1' --- code/SQLite3Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/SQLite3Database.php b/code/SQLite3Database.php index 48977cf..e9fdad9 100644 --- a/code/SQLite3Database.php +++ b/code/SQLite3Database.php @@ -939,7 +939,7 @@ class SQLite3Database extends SS_Database { * Does this database support transactions? */ public function supportsTransactions(){ - return !($this->getVersion() < 3.6); + return version_compare($this->getVersion(), '3.6', '>='); } /*