This commit is contained in:
parent
5aea10ec39
commit
1c4f4f665b
@ -681,6 +681,6 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module
|
||||
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EXPR) {
|
||||
throw new Doctrine_Expression_Exception('Unknown expression ' . $m);
|
||||
}
|
||||
return $m . '()';
|
||||
return $m . '(' . implode(', ', $a) . ')';
|
||||
}
|
||||
}
|
||||
|
@ -561,6 +561,11 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
// iterate through the component references within the aggregate function
|
||||
if ( ! empty ($components)) {
|
||||
foreach ($components as $component) {
|
||||
|
||||
if (is_numeric($component)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$e = explode('.', $component);
|
||||
|
||||
$field = array_pop($e);
|
||||
|
@ -87,4 +87,55 @@ class Doctrine_Query_Expression_TestCase extends Doctrine_UnitTestCase
|
||||
|
||||
$this->assertEqual($q->getQuery(), "SELECT CONCAT(e.name, 'The Man', e.loginname) AS e__0 FROM entity e WHERE (e.type = 0)");
|
||||
}
|
||||
|
||||
public function testNonPortableFunctionsAreSupported()
|
||||
{
|
||||
$query = new Doctrine_Query();
|
||||
// we are using stored procedure here, so adjust portability settings
|
||||
$this->conn->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL ^ Doctrine::PORTABILITY_EXPR);
|
||||
|
||||
$lat = '13.23';
|
||||
$lon = '33.23';
|
||||
$radius = '33';
|
||||
|
||||
$query->select("l.*, i18n.*, GeoDistKM(l.lat, l.lon, $lat, $lon) distance")
|
||||
->from('Location l, l.LocationI18n i18n')
|
||||
->where('l.id <> ? AND i18n.culture = ?', array(1, 'en'))
|
||||
->having("distance < $radius")
|
||||
->orderby('distance ASC')
|
||||
->groupby('l.id')
|
||||
->limit(5);
|
||||
|
||||
$this->assertEqual($query->getSql(), "SELECT l.id AS l__id, l.lat AS l__lat, l.lon AS l__lon, l2.name AS l2__name, l2.id AS l2__id, l2.culture AS l2__culture, GeoDistKM(l.lat, l.lon, 13.23, 33.23) AS l__0 FROM location l LEFT JOIN location_i18n l2 ON l.id = l2.id WHERE l.id IN (SELECT DISTINCT l3.id FROM location l3 LEFT JOIN location_i18n l4 ON l3.id = l4.id WHERE (l3.id <> ? AND l4.culture = ?) GROUP BY l3.id HAVING l__0 < 33 ORDER BY l__0 ASC LIMIT 5) AND (l.id <> ? AND l2.culture = ?) GROUP BY l.id HAVING l__0 < 33 ORDER BY l__0 ASC");
|
||||
|
||||
$this->conn->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL);
|
||||
}
|
||||
}
|
||||
class Location extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
$this->hasColumn('lat', 'double', 10, array ());
|
||||
$this->hasColumn('lon', 'double', 10, array ());
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasMany('LocationI18n as LocationI18n', array('local' => 'id', 'foreign' => 'id'));
|
||||
}
|
||||
}
|
||||
|
||||
class LocationI18n extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
$this->hasColumn('name', 'string', 50, array());
|
||||
$this->hasColumn('id', 'integer', 10, array('primary' => true));
|
||||
$this->hasColumn('culture', 'string', 2);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasOne('Location as Location', array('local' => 'id'));
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,6 @@ class Doctrine_UnitTestCase extends UnitTestCase
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->conn->export->exportClasses($this->tables);
|
||||
/**
|
||||
foreach($this->tables as $name) {
|
||||
|
Loading…
Reference in New Issue
Block a user