diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1474Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1474Test.php deleted file mode 100644 index e1256f3c32a..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1474Test.php +++ /dev/null @@ -1,122 +0,0 @@ -_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1474Entity'), - )); - - $this->loadFixtures(); - } catch (\Exception $exc) { - - } - } - - public function testTicket() - { - $query = $this->_em->createQuery('SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e'); - $this->assertEquals('SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_', $query->getSQL()); - $result = $query->getResult(); - - $this->assertEquals(2, sizeof($result)); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals(2, $result[1]['id']); - - $this->assertEquals(-10, $result[0]['value']); - $this->assertEquals(20, $result[1]['value']); - - - - - - $query = $this->_em->createQuery('SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e'); - $this->assertEquals('SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_', $query->getSQL()); - $result = $query->getResult(); - - $this->assertEquals(2, sizeof($result)); - - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals(2, $result[1]['id']); - - $this->assertEquals(10, $result[0]['value']); - $this->assertEquals(-20, $result[1]['value']); - } - - public function loadFixtures() - { - $e1 = new DDC1474Entity(10); - $e2 = new DDC1474Entity(-20); - - $this->_em->persist($e1); - $this->_em->persist($e2); - - $this->_em->flush(); - } - -} - -/** - * @Entity - */ -class DDC1474Entity -{ - - /** - * @Id - * @Column(type="integer") - * @GeneratedValue() - */ - protected $id; - - /** - * @column(type="float") - */ - private $value; - - /** - * @param string $float - */ - public function __construct($float) - { - $this->value = $float; - } - - /** - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * @return float - */ - public function getValue() - { - return $this->value; - } - - /** - * @param float $value - */ - public function setValue($value) - { - $this->value = $value; - } - -} diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 8eaaf37bb74..b2fdb59ad77 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1301,6 +1301,22 @@ public function testForeignKeyAsPrimaryKeySubselect() "SELECT d0_.article_id AS article_id0, d0_.title AS title1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)" ); } + + /** + * @group DDC-1474 + */ + public function testSelectWithArithmeticExpressionBeforeField() + { + $this->assertSqlGeneration( + 'SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e', + 'SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_' + ); + + $this->assertSqlGeneration( + 'SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e', + 'SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_' + ); + } } @@ -1343,3 +1359,57 @@ class DDC1384Model */ protected $aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; } + + +/** + * @Entity + */ +class DDC1474Entity +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue() + */ + protected $id; + + /** + * @column(type="float") + */ + private $value; + + /** + * @param string $float + */ + public function __construct($float) + { + $this->value = $float; + } + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * @param float $value + */ + public function setValue($value) + { + $this->value = $value; + } + +} +