diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php index 679ee85cc..b88a76939 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php @@ -61,7 +61,6 @@ class SimplifiedYamlDriver extends YamlDriver $this->_prefixes[$path] = $prefix; } - public function getNamespacePrefixes() { return $this->_prefixes; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1521Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1521Test.php new file mode 100644 index 000000000..b305c4005 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1521Test.php @@ -0,0 +1,77 @@ +useModelSet('navigation'); + + parent::setUp(); + + $config = $this->_em->getConfiguration(); + $config->addCustomNumericFunction('TEST', __NAMESPACE__ . '\TestFunction'); + } + + public function testIssue() + { + $dql = 'SELECT TEST(p.lat, p.long, :lat, :lng) FROM Doctrine\Tests\Models\Navigation\NavPointOfInterest p WHERE p.name = :name'; + $params = array('lat' => 1, 'lng' => 2, 'name' => 'My restaurant'); + + $query = $this->_em->createQuery($dql)->setParameters($params); + + $this->assertEquals('SELECT ((12733.129728 + (n0_.nav_lat - ?) + (n0_.nav_long - ?)) * ((n0_.nav_lat - ?) / (12733.129728 * n0_.nav_long - ?))) AS sclr0 FROM navigation_pois n0_ WHERE n0_.name = ?', $query->getSQL()); + + $result = $query->getScalarResult(); + + $this->assertEquals(0, count($result)); + } +} + +class TestFunction extends FunctionNode +{ + protected $fromLat; + protected $fromLng; + protected $toLat; + protected $toLng; + + public function parse(\Doctrine\ORM\Query\Parser $parser) + { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + + $this->fromLat = $parser->ArithmeticPrimary(); + $parser->match(Lexer::T_COMMA); + + $this->fromLng = $parser->ArithmeticPrimary(); + $parser->match(Lexer::T_COMMA); + + $this->toLat = $parser->ArithmeticPrimary(); + $parser->match(Lexer::T_COMMA); + + $this->toLng = $parser->ArithmeticPrimary(); + + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + } + + public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + { + $fromLat = $this->fromLat->dispatch($sqlWalker); + $fromLng = $this->fromLng->dispatch($sqlWalker); + $toLat = $this->toLat->dispatch($sqlWalker); + $toLng = $this->toLng->dispatch($sqlWalker); + + $earthDiameterInKM = 1.609344 * 3956 * 2; + + return "(($earthDiameterInKM + ($fromLat - $toLat) + ($fromLng - $toLng)) * (($fromLat - $toLat) / ($earthDiameterInKM * $fromLng - $toLng)))"; + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index e7b55eb1f..6af9cc547 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -2,14 +2,12 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Tests\Models\Qelista\User; - -use Doctrine\Tests\Models\Qelista\ShoppingList; - use Doctrine\Common\Collections\ArrayCollection; + use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; + require_once __DIR__ . '/../../../TestInit.php'; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index dc77ed60e..74c1fe1d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -46,6 +46,7 @@ class DDC1548E1 */ public $rel; } + /** * @Entity */