Skip to content
This repository

Rename DboSource property fullDebug to log #539

Closed
wants to merge 1 commit into from

3 participants

Cauan Cabral Mark Story ADmad
Cauan Cabral

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?

Cauan Cabral

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)

Mark Story
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?

Cauan Cabral

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
ADmad commented

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

Cauan Cabral

OK, stay for the next major release.

Mark Story
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.

Mark Story markstory closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 02, 2012
Cauan Cabral CauanCabral Rename DboSource::fullDebug to log cc71693
This page is out of date. Refresh to see the latest.
14 lib/Cake/Model/Datasource/DboSource.php
@@ -70,11 +70,11 @@ class DboSource extends DataSource {
70 70 public $cacheMethods = true;
71 71
72 72 /**
73   - * Print full query debug info?
  73 + * Enable full query log for debug or another application purpose
74 74 *
75 75 * @var boolean
76 76 */
77   - public $fullDebug = false;
  77 + public $log = false;
78 78
79 79 /**
80 80 * String to hold how many rows were affected by the last SQL operation.
@@ -234,7 +234,7 @@ public function __construct($config = null, $autoConnect = true) {
234 234 $config['prefix'] = '';
235 235 }
236 236 parent::__construct($config);
237   - $this->fullDebug = Configure::read('debug') > 1;
  237 + $this->log = Configure::read('debug') > 1;
238 238 if (!$this->enabled()) {
239 239 throw new MissingConnectionException(array(
240 240 'class' => get_class($this)
@@ -397,7 +397,7 @@ public function rawQuery($sql, $params = array()) {
397 397 * @return mixed Resource or object representing the result set, or false on failure
398 398 */
399 399 public function execute($sql, $options = array(), $params = array()) {
400   - $options += array('log' => $this->fullDebug);
  400 + $options += array('log' => $this->log);
401 401
402 402 $t = microtime(true);
403 403 $this->_result = $this->_execute($sql, $params);
@@ -2007,7 +2007,7 @@ public function truncate($table) {
2007 2007 */
2008 2008 public function begin() {
2009 2009 if ($this->_transactionStarted || $this->_connection->beginTransaction()) {
2010   - if ($this->fullDebug && empty($this->_transactionNesting)) {
  2010 + if ($this->log && empty($this->_transactionNesting)) {
2011 2011 $this->logQuery('BEGIN');
2012 2012 }
2013 2013 $this->_transactionStarted = true;
@@ -2030,7 +2030,7 @@ public function commit() {
2030 2030 if ($this->_transactionNesting <= 0) {
2031 2031 $this->_transactionStarted = false;
2032 2032 $this->_transactionNesting = 0;
2033   - if ($this->fullDebug) {
  2033 + if ($this->log) {
2034 2034 $this->logQuery('COMMIT');
2035 2035 }
2036 2036 return $this->_connection->commit();
@@ -2049,7 +2049,7 @@ public function commit() {
2049 2049 */
2050 2050 public function rollback() {
2051 2051 if ($this->_transactionStarted && $this->_connection->rollBack()) {
2052   - if ($this->fullDebug) {
  2052 + if ($this->log) {
2053 2053 $this->logQuery('ROLLBACK');
2054 2054 }
2055 2055 $this->_transactionStarted = false;
24 lib/Cake/Test/Case/Model/ModelReadTest.php
@@ -5831,8 +5831,8 @@ public function testReadFakeThread() {
5831 5831 $this->loadFixtures('CategoryThread');
5832 5832 $TestModel = new CategoryThread();
5833 5833
5834   - $fullDebug = $this->db->fullDebug;
5835   - $this->db->fullDebug = true;
  5834 + $log = $this->db->log;
  5835 + $this->db->log = true;
5836 5836 $TestModel->recursive = 6;
5837 5837 $TestModel->id = 7;
5838 5838 $result = $TestModel->read();
@@ -5882,7 +5882,7 @@ public function testReadFakeThread() {
5882 5882 'updated' => '2007-03-18 15:32:31'
5883 5883 )))))));
5884 5884
5885   - $this->db->fullDebug = $fullDebug;
  5885 + $this->db->log = $log;
5886 5886 $this->assertEquals($expected, $result);
5887 5887 }
5888 5888
@@ -5895,8 +5895,8 @@ public function testFindFakeThread() {
5895 5895 $this->loadFixtures('CategoryThread');
5896 5896 $TestModel = new CategoryThread();
5897 5897
5898   - $fullDebug = $this->db->fullDebug;
5899   - $this->db->fullDebug = true;
  5898 + $log = $this->db->log;
  5899 + $this->db->log = true;
5900 5900 $TestModel->recursive = 6;
5901 5901 $result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7)));
5902 5902
@@ -5946,7 +5946,7 @@ public function testFindFakeThread() {
5946 5946 'updated' => '2007-03-18 15:32:31'
5947 5947 )))))));
5948 5948
5949   - $this->db->fullDebug = $fullDebug;
  5949 + $this->db->log = $log;
5950 5950 $this->assertEquals($expected, $result);
5951 5951 }
5952 5952
@@ -5959,8 +5959,8 @@ public function testFindAllFakeThread() {
5959 5959 $this->loadFixtures('CategoryThread');
5960 5960 $TestModel = new CategoryThread();
5961 5961
5962   - $fullDebug = $this->db->fullDebug;
5963   - $this->db->fullDebug = true;
  5962 + $log = $this->db->log;
  5963 + $this->db->log = true;
5964 5964 $TestModel->recursive = 6;
5965 5965 $result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
5966 5966 $expected = array(
@@ -6166,7 +6166,7 @@ public function testFindAllFakeThread() {
6166 6166 'updated' => '2007-03-18 15:32:31'
6167 6167 ))))))));
6168 6168
6169   - $this->db->fullDebug = $fullDebug;
  6169 + $this->db->log = $log;
6170 6170 $this->assertEquals($expected, $result);
6171 6171 }
6172 6172
@@ -6783,11 +6783,11 @@ public function testFindCount() {
6783 6783 $this->assertEquals($result, 4);
6784 6784
6785 6785 $this->db->getLog(false, true);
6786   - $fullDebug = $this->db->fullDebug;
6787   - $this->db->fullDebug = true;
  6786 + $log = $this->db->log;
  6787 + $this->db->log = true;
6788 6788 $TestModel->order = 'User.id';
6789 6789 $result = $TestModel->find('count');
6790   - $this->db->fullDebug = $fullDebug;
  6790 + $this->db->log = $log;
6791 6791 $this->assertEquals($result, 4);
6792 6792
6793 6793 $log = $this->db->getLog();
12 lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php
@@ -185,7 +185,7 @@ public function setUp() {
185 185 $methods[] = 'connect';
186 186
187 187 $this->criticDb = $this->getMock('DboSource', $methods);
188   - $this->criticDb->fullDebug = true;
  188 + $this->criticDb->log = true;
189 189 $this->db = ConnectionManager::getDataSource('test');
190 190 $this->_backupConfig = $this->db->config;
191 191 }
@@ -383,7 +383,7 @@ public function testCreate() {
383 383 $this->criticDb->expects($this->atLeastOnce())->method('execute');
384 384 $this->criticDb->expects($this->atLeastOnce())->method('createSchema');
385 385 $return = $Fixture->create($this->criticDb);
386   - $this->assertTrue($this->criticDb->fullDebug);
  386 + $this->assertTrue($this->criticDb->log);
387 387 $this->assertTrue($return);
388 388
389 389 unset($Fixture->fields);
@@ -404,7 +404,7 @@ public function testInsert() {
404 404
405 405 $return = $Fixture->insert($this->criticDb);
406 406 $this->assertTrue(!empty($this->insertMulti));
407   - $this->assertTrue($this->criticDb->fullDebug);
  407 + $this->assertTrue($this->criticDb->log);
408 408 $this->assertTrue($return);
409 409 $this->assertEquals('fixture_tests', $this->insertMulti['table']);
410 410 $this->assertEquals(array('name', 'created'), $this->insertMulti['fields']);
@@ -443,7 +443,7 @@ public function testInsertStrings() {
443 443 ->will($this->returnCallback(array($this, 'insertCallback')));
444 444
445 445 $return = $Fixture->insert($this->criticDb);
446   - $this->assertTrue($this->criticDb->fullDebug);
  446 + $this->assertTrue($this->criticDb->log);
447 447 $this->assertTrue($return);
448 448 $this->assertEquals('strings', $this->insertMulti['table']);
449 449 $this->assertEquals(array('email', 'name', 'age'), $this->insertMulti['fields']);
@@ -467,7 +467,7 @@ public function testDrop() {
467 467 $this->criticDb->expects($this->exactly(2))->method('dropSchema');
468 468
469 469 $return = $Fixture->drop($this->criticDb);
470   - $this->assertTrue($this->criticDb->fullDebug);
  470 + $this->assertTrue($this->criticDb->log);
471 471 $this->assertTrue($return);
472 472
473 473 $return = $Fixture->drop($this->criticDb);
@@ -487,6 +487,6 @@ public function testTruncate() {
487 487 $Fixture = new CakeTestFixtureTestFixture();
488 488 $this->criticDb->expects($this->atLeastOnce())->method('truncate');
489 489 $Fixture->truncate($this->criticDb);
490   - $this->assertTrue($this->criticDb->fullDebug);
  490 + $this->assertTrue($this->criticDb->log);
491 491 }
492 492 }
6 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
@@ -249,10 +249,10 @@ public function insert($db) {
249 249 * @return boolean
250 250 */
251 251 public function truncate($db) {
252   - $fullDebug = $db->fullDebug;
253   - $db->fullDebug = false;
  252 + $log = $db->log;
  253 + $db->log = false;
254 254 $return = $db->truncate($this->table);
255   - $db->fullDebug = $fullDebug;
  255 + $db->log = $log;
256 256 return $return;
257 257 }
258 258 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.