Skip to content

Commit

Permalink
Sqlite is failing in PHP 5.2, re-adding the check for driver support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 14, 2012
1 parent ffe0a18 commit a512d46
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Mysql.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public function getSchemaName() {
* *
* @return boolean * @return boolean
*/ */
protected function _supportNestedTransaction() { public function supportNestedTransaction() {
return version_compare($this->getVersion(), '4.1', '>='); return version_compare($this->getVersion(), '4.1', '>=');
} }


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Postgres.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ public function getSchemaName() {
* *
* @return boolean * @return boolean
*/ */
protected function _supportNestedTransaction() { public function supportNestedTransaction() {
return version_compare($this->getVersion(), '8.0', '>='); return version_compare($this->getVersion(), '8.0', '>=');
} }


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlite.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public function getSchemaName() {
* *
* @return boolean * @return boolean
*/ */
protected function _supportNestedTransaction() { public function supportNestedTransaction() {
return version_compare($this->getVersion(), '3.6.8', '>='); return version_compare($this->getVersion(), '3.6.8', '>=');
} }


Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Model/Datasource/DboSource.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ public function truncate($table) {
* *
* @return boolean * @return boolean
*/ */
protected function _supportNestedTransaction() { public function supportNestedTransaction() {

This comment has been minimized.

Copy link
@ADmad

ADmad Apr 26, 2012

Member

A more grammatically correct name for the function would be $supportsNestedTransaction() ("supports" with an "s")

Edit: $supportsNestedTransaction() should read supportsNestedTransaction() :)

This comment has been minimized.

Copy link
@tPl0ch

tPl0ch Apr 26, 2012

Grammar Nazi :p

This comment has been minimized.

Copy link
@AD7six

AD7six Apr 26, 2012

Member

appropriate though - otherwise it sounds like a function that makes nested transactions supported

This comment has been minimized.

Copy link
@ceeram

ceeram Apr 26, 2012

Contributor

nestedTransactionSupported()

This comment has been minimized.

Copy link
@tPl0ch

tPl0ch Apr 26, 2012

+1 for Ceeram

<?php
    if ($this->nestedTransactionSupported()) {
        doMagic();
    }
?>

looks very readable to me and tells me exactly what the method does.

This comment has been minimized.

Copy link
@ADmad

ADmad Apr 26, 2012

Member

@tPl0ch When it comes to API method/property names, its good to be picky, pedantic even. Otherwise you have to live with incorrect / inaccurate / inconsistent names until the next major release as they cannot be changed easily. PHP itself is a prime example of inconsistent naming we should learn from it :)

return false; return false;
} }


Expand All @@ -2035,7 +2035,7 @@ protected function _supportNestedTransaction() {
*/ */
public function begin() { public function begin() {
if ($this->_transactionStarted) { if ($this->_transactionStarted) {
if ($this->_supportNestedTransaction()) { if ($this->supportNestedTransaction()) {
return $this->_beginNested(); return $this->_beginNested();
} }
$this->_transactionNesting++; $this->_transactionNesting++;
Expand Down Expand Up @@ -2083,7 +2083,7 @@ public function commit() {
return $this->_connection->commit(); return $this->_connection->commit();
} }


if ($this->_supportNestedTransaction()) { if ($this->supportNestedTransaction()) {
return $this->_commitNested(); return $this->_commitNested();
} }


Expand Down Expand Up @@ -2125,7 +2125,7 @@ public function rollback() {
return $this->_connection->rollBack(); return $this->_connection->rollBack();
} }


if ($this->_supportNestedTransaction()) { if ($this->supportNestedTransaction()) {
return $this->_rollbackNested(); return $this->_rollbackNested();
} }


Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3586,6 +3586,8 @@ public function testTruncateStatements() {
* @return void * @return void
*/ */
public function testNestedTransaction() { public function testNestedTransaction() {
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The MySQL server do not support nested transaction');

$this->loadFixtures('Address'); $this->loadFixtures('Address');
$model = ClassRegistry::init('Address'); $model = ClassRegistry::init('Address');
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ public function testTruncateStatements() {
* @return void * @return void
*/ */
public function testNestedTransaction() { public function testNestedTransaction() {
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The Postgres server do not support nested transaction');

$this->loadFixtures('Article'); $this->loadFixtures('Article');
$model = new Article(); $model = new Article();
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ public function testUuidPrimaryKeyInsertion() {
* @return void * @return void
*/ */
public function testNestedTransaction() { public function testNestedTransaction() {
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The Sqlite version do not support nested transaction');

$this->loadFixtures('User'); $this->loadFixtures('User');
$model = new User(); $model = new User();
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
Expand Down

0 comments on commit a512d46

Please sign in to comment.