Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Rename DboSource property fullDebug to log #539

Closed
wants to merge 1 commit into from

3 participants

@CauanCabral

Some people want to save Cake generated queries for your purpose and I think only renaming one property can make this more easy to understand.

DboSource have a property named fullDebug wich receive value from condition Configure::read('debug') > 1
But the property is public and can be used to enable query log without outputing it in sql_dump element.

What do you think of rename him to 'log', so everyone will see it like a configurable setting for different purposes?

@CauanCabral

One issue related at Lighthouseapp: http://cakephp.lighthouseapp.com/projects/42648/tickets/1082-ability-to-log-sql-queries-to-file-for-debugging-purposes (yes, I know that issue had tagged with won't-fix)

@markstory
Owner

I don't get what benefit is gained from renaming a property. Also won't this break userland applications that are modifying the existing fullDebug?

@CauanCabral

The only benefit is semantic.

I think the original name is not appropriate for that property behavior, because if I override it value, DboSource will log my queries, without output to sql_dump (to output, 'debug' config is read again)

About break userland applications, I agree, but the change necessary is minimal (like a find/replace).

@ADmad
Collaborator

We can review/change the name in next major release. There is no point causing grief to users over a small semantic change.

@CauanCabral

OK, stay for the next major release.

@markstory
Owner

Closing this as for 3.0 the database layer is basically being re-written and we can use a better name at that time.

@markstory markstory closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 2, 2012
  1. @CauanCabral
This page is out of date. Refresh to see the latest.
View
14 lib/Cake/Model/Datasource/DboSource.php
@@ -70,11 +70,11 @@ class DboSource extends DataSource {
public $cacheMethods = true;
/**
- * Print full query debug info?
+ * Enable full query log for debug or another application purpose
*
* @var boolean
*/
- public $fullDebug = false;
+ public $log = false;
/**
* String to hold how many rows were affected by the last SQL operation.
@@ -234,7 +234,7 @@ public function __construct($config = null, $autoConnect = true) {
$config['prefix'] = '';
}
parent::__construct($config);
- $this->fullDebug = Configure::read('debug') > 1;
+ $this->log = Configure::read('debug') > 1;
if (!$this->enabled()) {
throw new MissingConnectionException(array(
'class' => get_class($this)
@@ -397,7 +397,7 @@ public function rawQuery($sql, $params = array()) {
* @return mixed Resource or object representing the result set, or false on failure
*/
public function execute($sql, $options = array(), $params = array()) {
- $options += array('log' => $this->fullDebug);
+ $options += array('log' => $this->log);
$t = microtime(true);
$this->_result = $this->_execute($sql, $params);
@@ -2007,7 +2007,7 @@ public function truncate($table) {
*/
public function begin() {
if ($this->_transactionStarted || $this->_connection->beginTransaction()) {
- if ($this->fullDebug && empty($this->_transactionNesting)) {
+ if ($this->log && empty($this->_transactionNesting)) {
$this->logQuery('BEGIN');
}
$this->_transactionStarted = true;
@@ -2030,7 +2030,7 @@ public function commit() {
if ($this->_transactionNesting <= 0) {
$this->_transactionStarted = false;
$this->_transactionNesting = 0;
- if ($this->fullDebug) {
+ if ($this->log) {
$this->logQuery('COMMIT');
}
return $this->_connection->commit();
@@ -2049,7 +2049,7 @@ public function commit() {
*/
public function rollback() {
if ($this->_transactionStarted && $this->_connection->rollBack()) {
- if ($this->fullDebug) {
+ if ($this->log) {
$this->logQuery('ROLLBACK');
}
$this->_transactionStarted = false;
View
24 lib/Cake/Test/Case/Model/ModelReadTest.php
@@ -5831,8 +5831,8 @@ public function testReadFakeThread() {
$this->loadFixtures('CategoryThread');
$TestModel = new CategoryThread();
- $fullDebug = $this->db->fullDebug;
- $this->db->fullDebug = true;
+ $log = $this->db->log;
+ $this->db->log = true;
$TestModel->recursive = 6;
$TestModel->id = 7;
$result = $TestModel->read();
@@ -5882,7 +5882,7 @@ public function testReadFakeThread() {
'updated' => '2007-03-18 15:32:31'
)))))));
- $this->db->fullDebug = $fullDebug;
+ $this->db->log = $log;
$this->assertEquals($expected, $result);
}
@@ -5895,8 +5895,8 @@ public function testFindFakeThread() {
$this->loadFixtures('CategoryThread');
$TestModel = new CategoryThread();
- $fullDebug = $this->db->fullDebug;
- $this->db->fullDebug = true;
+ $log = $this->db->log;
+ $this->db->log = true;
$TestModel->recursive = 6;
$result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7)));
@@ -5946,7 +5946,7 @@ public function testFindFakeThread() {
'updated' => '2007-03-18 15:32:31'
)))))));
- $this->db->fullDebug = $fullDebug;
+ $this->db->log = $log;
$this->assertEquals($expected, $result);
}
@@ -5959,8 +5959,8 @@ public function testFindAllFakeThread() {
$this->loadFixtures('CategoryThread');
$TestModel = new CategoryThread();
- $fullDebug = $this->db->fullDebug;
- $this->db->fullDebug = true;
+ $log = $this->db->log;
+ $this->db->log = true;
$TestModel->recursive = 6;
$result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
$expected = array(
@@ -6166,7 +6166,7 @@ public function testFindAllFakeThread() {
'updated' => '2007-03-18 15:32:31'
))))))));
- $this->db->fullDebug = $fullDebug;
+ $this->db->log = $log;
$this->assertEquals($expected, $result);
}
@@ -6783,11 +6783,11 @@ public function testFindCount() {
$this->assertEquals($result, 4);
$this->db->getLog(false, true);
- $fullDebug = $this->db->fullDebug;
- $this->db->fullDebug = true;
+ $log = $this->db->log;
+ $this->db->log = true;
$TestModel->order = 'User.id';
$result = $TestModel->find('count');
- $this->db->fullDebug = $fullDebug;
+ $this->db->log = $log;
$this->assertEquals($result, 4);
$log = $this->db->getLog();
View
12 lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php
@@ -185,7 +185,7 @@ public function setUp() {
$methods[] = 'connect';
$this->criticDb = $this->getMock('DboSource', $methods);
- $this->criticDb->fullDebug = true;
+ $this->criticDb->log = true;
$this->db = ConnectionManager::getDataSource('test');
$this->_backupConfig = $this->db->config;
}
@@ -383,7 +383,7 @@ public function testCreate() {
$this->criticDb->expects($this->atLeastOnce())->method('execute');
$this->criticDb->expects($this->atLeastOnce())->method('createSchema');
$return = $Fixture->create($this->criticDb);
- $this->assertTrue($this->criticDb->fullDebug);
+ $this->assertTrue($this->criticDb->log);
$this->assertTrue($return);
unset($Fixture->fields);
@@ -404,7 +404,7 @@ public function testInsert() {
$return = $Fixture->insert($this->criticDb);
$this->assertTrue(!empty($this->insertMulti));
- $this->assertTrue($this->criticDb->fullDebug);
+ $this->assertTrue($this->criticDb->log);
$this->assertTrue($return);
$this->assertEquals('fixture_tests', $this->insertMulti['table']);
$this->assertEquals(array('name', 'created'), $this->insertMulti['fields']);
@@ -443,7 +443,7 @@ public function testInsertStrings() {
->will($this->returnCallback(array($this, 'insertCallback')));
$return = $Fixture->insert($this->criticDb);
- $this->assertTrue($this->criticDb->fullDebug);
+ $this->assertTrue($this->criticDb->log);
$this->assertTrue($return);
$this->assertEquals('strings', $this->insertMulti['table']);
$this->assertEquals(array('email', 'name', 'age'), $this->insertMulti['fields']);
@@ -467,7 +467,7 @@ public function testDrop() {
$this->criticDb->expects($this->exactly(2))->method('dropSchema');
$return = $Fixture->drop($this->criticDb);
- $this->assertTrue($this->criticDb->fullDebug);
+ $this->assertTrue($this->criticDb->log);
$this->assertTrue($return);
$return = $Fixture->drop($this->criticDb);
@@ -487,6 +487,6 @@ public function testTruncate() {
$Fixture = new CakeTestFixtureTestFixture();
$this->criticDb->expects($this->atLeastOnce())->method('truncate');
$Fixture->truncate($this->criticDb);
- $this->assertTrue($this->criticDb->fullDebug);
+ $this->assertTrue($this->criticDb->log);
}
}
View
6 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
@@ -249,10 +249,10 @@ public function insert($db) {
* @return boolean
*/
public function truncate($db) {
- $fullDebug = $db->fullDebug;
- $db->fullDebug = false;
+ $log = $db->log;
+ $db->log = false;
$return = $db->truncate($this->table);
- $db->fullDebug = $fullDebug;
+ $db->log = $log;
return $return;
}
}
Something went wrong with that request. Please try again.