Merge pull request #378 from web-dev/DDC-1880
Fixed DDC-1880 Named Queries not registered in xml mapping
This commit is contained in:
commit
41d9f612c7
@ -76,7 +76,7 @@ class XmlDriver extends AbstractFileDriver
|
|||||||
$metadata->setPrimaryTable($table);
|
$metadata->setPrimaryTable($table);
|
||||||
|
|
||||||
// Evaluate named queries
|
// Evaluate named queries
|
||||||
if (isset($xmlRoot['named-queries'])) {
|
if (isset($xmlRoot->{'named-queries'})) {
|
||||||
foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) {
|
foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) {
|
||||||
$metadata->addNamedQuery(array(
|
$metadata->addNamedQuery(array(
|
||||||
'name' => (string)$namedQueryElement['name'],
|
'name' => (string)$namedQueryElement['name'],
|
||||||
|
@ -485,6 +485,14 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$factory->getMetadataFor('Doctrine\Tests\Models\DDC889\DDC889Entity');
|
$factory->getMetadataFor('Doctrine\Tests\Models\DDC889\DDC889Entity');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNamedQuery()
|
||||||
|
{
|
||||||
|
$driver = $this->_loadDriver();
|
||||||
|
$class = $this->createClassMetadata(__NAMESPACE__.'\User');
|
||||||
|
|
||||||
|
$this->assertCount(1, $class->getNamedQueries(), sprintf("Named queries not processed correctly by driver %s", get_class($driver)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-1663
|
* @group DDC-1663
|
||||||
*/
|
*/
|
||||||
@ -742,6 +750,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
* indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"})},
|
* indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"})},
|
||||||
* options={"foo": "bar", "baz": {"key": "val"}}
|
* options={"foo": "bar", "baz": {"key": "val"}}
|
||||||
* )
|
* )
|
||||||
|
* @NamedQueries({@NamedQuery(name="all", query="SELECT u FROM __CLASS__ u")})
|
||||||
*/
|
*/
|
||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
@ -921,6 +930,10 @@ class User
|
|||||||
'allocationSize' => 100,
|
'allocationSize' => 100,
|
||||||
'initialValue' => 1,
|
'initialValue' => 1,
|
||||||
));
|
));
|
||||||
|
$metadata->addNamedQuery(array(
|
||||||
|
'name' => 'all',
|
||||||
|
'query' => 'SELECT u FROM __CLASS__ u'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user