fixes #359
This commit is contained in:
parent
f86ac4c8e2
commit
612793d9cb
@ -102,6 +102,10 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
'parserCache' => false,
|
'parserCache' => false,
|
||||||
'resultSetCache' => false,
|
'resultSetCache' => false,
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* @var string $_sql cached SQL query
|
||||||
|
*/
|
||||||
|
protected $_sql;
|
||||||
/**
|
/**
|
||||||
* @var array $parts SQL query string parts
|
* @var array $parts SQL query string parts
|
||||||
*/
|
*/
|
||||||
@ -643,7 +647,6 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
public function _execute($params, $return = Doctrine::FETCH_RECORD)
|
public function _execute($params, $return = Doctrine::FETCH_RECORD)
|
||||||
{
|
{
|
||||||
$params = $this->_conn->convertBooleans(array_merge($this->_params, $params));
|
$params = $this->_conn->convertBooleans(array_merge($this->_params, $params));
|
||||||
$params = $this->convertEnums($params);
|
|
||||||
|
|
||||||
if ( ! $this->_view) {
|
if ( ! $this->_view) {
|
||||||
$query = $this->getQuery($params);
|
$query = $this->getQuery($params);
|
||||||
@ -651,6 +654,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
$query = $this->_view->getSelectSql();
|
$query = $this->_view->getSelectSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$params = $this->convertEnums($params);
|
||||||
|
|
||||||
if ($this->isLimitSubqueryUsed() &&
|
if ($this->isLimitSubqueryUsed() &&
|
||||||
$this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
|
$this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
|
||||||
@ -662,7 +666,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
|
|||||||
return $this->_conn->exec($query, $params);
|
return $this->_conn->exec($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $this->_conn->execute($query, $params);
|
$stmt = $this->_conn->execute($query, $params);
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
}
|
}
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->_enumParams = array();
|
|
||||||
$this->_pendingJoinConditions = array();
|
$this->_pendingJoinConditions = array();
|
||||||
$this->pendingSubqueries = array();
|
$this->pendingSubqueries = array();
|
||||||
$this->pendingFields = array();
|
$this->pendingFields = array();
|
||||||
@ -305,6 +304,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_state = Doctrine_Query::STATE_DIRTY;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -688,6 +689,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
*/
|
*/
|
||||||
public function getQuery($params = array())
|
public function getQuery($params = array())
|
||||||
{
|
{
|
||||||
|
if ($this->_state !== self::STATE_DIRTY) {
|
||||||
|
return $this->_sql;
|
||||||
|
}
|
||||||
|
|
||||||
$parts = $this->_dqlParts;
|
$parts = $this->_dqlParts;
|
||||||
|
|
||||||
// reset the state
|
// reset the state
|
||||||
@ -722,6 +727,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$params = $this->convertEnums($params);
|
||||||
|
|
||||||
$this->_state = self::STATE_DIRECT;
|
$this->_state = self::STATE_DIRECT;
|
||||||
|
|
||||||
// invoke the preQuery hook
|
// invoke the preQuery hook
|
||||||
@ -814,6 +821,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
if ($needsSubQuery) {
|
if ($needsSubQuery) {
|
||||||
array_shift($this->parts['where']);
|
array_shift($this->parts['where']);
|
||||||
}
|
}
|
||||||
|
$this->_sql = $q;
|
||||||
|
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,9 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$query = new Doctrine_Query($this->connection);
|
$query = new Doctrine_Query($this->connection);
|
||||||
$ret = $query->query('FROM EnumTest WHERE EnumTest.status = ?', array('open'));
|
$ret = $query->parseQuery('FROM EnumTest WHERE EnumTest.status = ?')
|
||||||
|
->execute(array('open'));
|
||||||
|
|
||||||
$this->assertEqual(count($ret), 1);
|
$this->assertEqual(count($ret), 1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->fail();
|
$this->fail();
|
||||||
@ -108,22 +110,22 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
|
|||||||
{
|
{
|
||||||
|
|
||||||
$enum = new EnumTest();
|
$enum = new EnumTest();
|
||||||
$enum->status = "open";
|
$enum->status = 'open';
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
$enum->save();
|
$enum->save();
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
$enum->refresh();
|
$enum->refresh();
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
|
|
||||||
$enum->status = "closed";
|
$enum->status = 'closed';
|
||||||
|
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
|
|
||||||
$enum->save();
|
$enum->save();
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
$this->assertTrue(is_numeric($enum->id));
|
$this->assertTrue(is_numeric($enum->id));
|
||||||
$enum->refresh();
|
$enum->refresh();
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnumTypeWithCaseConversion()
|
public function testEnumTypeWithCaseConversion()
|
||||||
@ -132,24 +134,24 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$enum = new EnumTest();
|
$enum = new EnumTest();
|
||||||
|
|
||||||
$enum->status = "open";
|
$enum->status = 'open';
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
|
|
||||||
$enum->save();
|
$enum->save();
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
|
|
||||||
$enum->refresh();
|
$enum->refresh();
|
||||||
$this->assertEqual($enum->status, "open");
|
$this->assertEqual($enum->status, 'open');
|
||||||
|
|
||||||
$enum->status = "closed";
|
$enum->status = 'closed';
|
||||||
|
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
|
|
||||||
$enum->save();
|
$enum->save();
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
|
|
||||||
$enum->refresh();
|
$enum->refresh();
|
||||||
$this->assertEqual($enum->status, "closed");
|
$this->assertEqual($enum->status, 'closed');
|
||||||
|
|
||||||
$this->conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
|
$this->conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
|
|||||||
|
|
||||||
$test->addTestCase(new Doctrine_Ticket330_TestCase());
|
$test->addTestCase(new Doctrine_Ticket330_TestCase());
|
||||||
*/
|
*/
|
||||||
/**
|
/** */
|
||||||
// Connection drivers (not yet fully tested)
|
// Connection drivers (not yet fully tested)
|
||||||
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
||||||
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
||||||
@ -150,7 +150,7 @@ $test->addTestCase(new Doctrine_Expression_Oracle_TestCase());
|
|||||||
$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
|
$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
*/
|
|
||||||
$test->addTestCase(new Doctrine_Access_TestCase());
|
$test->addTestCase(new Doctrine_Access_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_Configurable_TestCase());
|
//$test->addTestCase(new Doctrine_Configurable_TestCase());
|
||||||
|
|
||||||
@ -180,8 +180,8 @@ $test->addTestCase(new Doctrine_Relation_Parser_TestCase());
|
|||||||
// Datatypes
|
// Datatypes
|
||||||
$test->addTestCase(new Doctrine_Enum_TestCase());
|
$test->addTestCase(new Doctrine_Enum_TestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_Boolean_TestCase());
|
|
||||||
|
|
||||||
|
$test->addTestCase(new Doctrine_Boolean_TestCase());
|
||||||
|
|
||||||
// Utility components
|
// Utility components
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ $test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
|
|||||||
$test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
|
$test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_Query_TestCase());
|
$test->addTestCase(new Doctrine_Query_TestCase());
|
||||||
/** */
|
|
||||||
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
|
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
|
||||||
|
|
||||||
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
|
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
|
||||||
|
Loading…
Reference in New Issue
Block a user