diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst
index 8e16b83abf..394b0a9a4b 100644
--- a/docs/en/reference/annotations-reference.rst
+++ b/docs/en/reference/annotations-reference.rst
@@ -395,9 +395,6 @@ Optional attributes:
repositoryClass - Specifies a custom repository class to use.
-
indexes - Specifies an array of indexes for this document.
--
- requireIndexes - Specifies whether or not queries for this document should
- require indexes by default. This may also be specified per query.
-
writeConcern - Specifies the write concern for this document that overwrites
the default write concern specified in the configuration. It does not overwrite
@@ -415,8 +412,7 @@ Optional attributes:
* repositoryClass="MyProject\UserRepository",
* indexes={
* @Index(keys={"username"="desc"}, options={"unique"=true})
- * },
- * requireIndexes=true
+ * }
* )
*/
class User
@@ -424,9 +420,6 @@ Optional attributes:
//...
}
-.. note::
- Requiring Indexes was deprecated in 1.2 and will be removed in 2.0.
-
@EmbedMany
----------
diff --git a/docs/en/reference/indexes.rst b/docs/en/reference/indexes.rst
index 6c527dd94b..3761b6b929 100644
--- a/docs/en/reference/indexes.rst
+++ b/docs/en/reference/indexes.rst
@@ -439,111 +439,3 @@ index.
Partial indexes are only available with MongoDB 3.2 or newer. For more
information on partial filter expressions, read the
`official MongoDB documentation `_.
-
-Requiring Indexes
------------------
-
-.. note::
- Requiring Indexes was deprecated in 1.2 and will be removed in 2.0.
-
-Sometimes you may want to require indexes for all your queries to ensure you don't let stray unindexed queries
-make it to the database and cause performance problems.
-
-
-.. configuration-block::
-
- .. code-block:: php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- .. code-block:: yaml
-
- # Documents.Place.dcm.yml
-
- Documents\Place:
- fields:
- id:
- id: true
- city:
- type: string
- indexes:
- index1:
- keys:
- city: asc
-
-When you run queries it will check that it is indexed and throw an exception if it is not indexed:
-
-.. code-block:: php
-
- createQueryBuilder('Documents\Place')
- ->field('city')->equals('Nashville');
- $query = $qb->getQuery();
- $places = $query->execute();
-
-When you execute the query it will throw an exception if `city` was not indexed in the database. You can control
-whether or not an exception will be thrown by using the `requireIndexes()` method:
-
-.. code-block:: php
-
- requireIndexes(false);
-
-You can also check if the query is indexed and with the `isIndexed()` method and use it to display your
-own notification when a query is unindexed:
-
-.. code-block:: php
-
- getQuery();
- if (!$query->isIndexed()) {
- $notifier->addError('Cannot execute queries that are not indexed.');
- }
-
-If you don't want to require indexes for all queries you can set leave `requireIndexes` as false and control
-it on a per query basis:
-
-.. code-block:: php
-
- requireIndexes(true);
- $query = $qb->getQuery();
- $results = $query->execute();
diff --git a/doctrine-mongo-mapping.xsd b/doctrine-mongo-mapping.xsd
index 57a60acd86..0ba9eb5f25 100644
--- a/doctrine-mongo-mapping.xsd
+++ b/doctrine-mongo-mapping.xsd
@@ -55,7 +55,6 @@
-
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php
index e0abc94301..fb2317c68e 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/Document.php
@@ -30,8 +30,6 @@ final class Document extends AbstractDocument
public $collection;
public $repositoryClass;
public $indexes = array();
- /** @deprecated */
- public $requireIndexes = false;
public $shardKey;
public $slaveOkay;
public $writeConcern;
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
index 675bd1decc..90dbf30ca6 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
@@ -225,13 +225,6 @@ class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMet
*/
public $shardKey;
- /**
- * READ-ONLY: Whether or not queries on this document should require indexes.
- *
- * @deprecated property was deprecated in 1.2 and will be removed in 2.0
- */
- public $requireIndexes = false;
-
/**
* READ-ONLY: The name of the document class.
*/
@@ -805,18 +798,6 @@ public function addIndex($keys, array $options = array())
);
}
- /**
- * Set whether or not queries on this document should require indexes.
- *
- * @param bool $requireIndexes
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public function setRequireIndexes($requireIndexes)
- {
- $this->requireIndexes = $requireIndexes;
- }
-
/**
* Returns the array of indexes for this Document.
*
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
index 14c2d29bbb..dbd706b96c 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
@@ -128,9 +128,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
$this->addIndex($class, $index);
}
}
- if (isset($documentAnnot->requireIndexes)) {
- $class->setRequireIndexes($documentAnnot->requireIndexes);
- }
if (isset($documentAnnot->slaveOkay)) {
$class->setSlaveOkay($documentAnnot->slaveOkay);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
index 82e4408a33..1b05404b12 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
@@ -121,9 +121,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
if (isset($xmlRoot->{'shard-key'})) {
$this->setShardKey($class, $xmlRoot->{'shard-key'}[0]);
}
- if (isset($xmlRoot['require-indexes'])) {
- $class->setRequireIndexes('true' === (string) $xmlRoot['require-indexes']);
- }
if (isset($xmlRoot['slave-okay'])) {
$class->setSlaveOkay('true' === (string) $xmlRoot['slave-okay']);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php
index 95fd1fdaab..e9a5dd52a8 100644
--- a/lib/Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php
+++ b/lib/Doctrine/ODM/MongoDB/Mapping/Driver/YamlDriver.php
@@ -100,9 +100,6 @@ public function loadMetadataForClass($className, ClassMetadata $class)
if (isset($element['changeTrackingPolicy'])) {
$class->setChangeTrackingPolicy(constant(MappingClassMetadata::class . '::CHANGETRACKING_' . strtoupper($element['changeTrackingPolicy'])));
}
- if (isset($element['requireIndexes'])) {
- $class->setRequireIndexes($element['requireIndexes']);
- }
if (isset($element['slaveOkay'])) {
$class->setSlaveOkay($element['slaveOkay']);
}
diff --git a/lib/Doctrine/ODM/MongoDB/MongoDBException.php b/lib/Doctrine/ODM/MongoDB/MongoDBException.php
index a48eb15cc7..db351fd82f 100644
--- a/lib/Doctrine/ODM/MongoDB/MongoDBException.php
+++ b/lib/Doctrine/ODM/MongoDB/MongoDBException.php
@@ -98,21 +98,6 @@ public static function cannotPersistMappedSuperclass($className)
return new self('Cannot persist an embedded document or mapped superclass ' . $className);
}
- /**
- * @param string $className
- * @param string $unindexedFields
- * @return MongoDBException
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public static function queryNotIndexed($className, $unindexedFields)
- {
- return new self(sprintf('Cannot execute unindexed queries on %s. Unindexed fields: %s',
- $className,
- implode(', ', $unindexedFields)
- ));
- }
-
/**
* @param string $className
* @return MongoDBException
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Builder.php b/lib/Doctrine/ODM/MongoDB/Query/Builder.php
index 4f5d766853..92df1dfaac 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Builder.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Builder.php
@@ -73,13 +73,6 @@ class Builder extends \Doctrine\MongoDB\Query\Builder
*/
private $primers = array();
- /**
- * Whether or not to require indexes.
- *
- * @var bool
- */
- private $requireIndexes;
-
/**
* Whether or not to register documents in UnitOfWork.
*
@@ -102,20 +95,6 @@ public function __construct(DocumentManager $dm, $documentName = null)
}
}
- /**
- * Set whether or not to require indexes.
- *
- * @param bool $requireIndexes
- * @return $this
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public function requireIndexes($requireIndexes = true)
- {
- $this->requireIndexes = $requireIndexes;
- return $this;
- }
-
/**
* Set the current field to operate on.
*
@@ -377,7 +356,6 @@ public function getQuery(array $options = array())
$this->hydrate,
$this->refresh,
$this->primers,
- $this->requireIndexes,
$this->readOnly
);
}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/FieldExtractor.php b/lib/Doctrine/ODM/MongoDB/Query/FieldExtractor.php
deleted file mode 100644
index 48859a2b89..0000000000
--- a/lib/Doctrine/ODM/MongoDB/Query/FieldExtractor.php
+++ /dev/null
@@ -1,96 +0,0 @@
-.
- */
-
-namespace Doctrine\ODM\MongoDB\Query;
-
-/**
- * Class responsible for extracting an array of field names that are involved in
- * a given mongodb query. Used for checking if query is indexed.
- *
- * @see Doctrine\ODM\MongoDB\Query::isIndexed()
- *
- * @deprecated class was deprecated in 1.2 and will be removed in 2.0
- */
-class FieldExtractor
-{
- private $query;
- private $sort;
-
- public function __construct(array $query, array $sort = array())
- {
- $this->query = $query;
- $this->sort = $sort;
- }
-
- public function getFields()
- {
- $fields = array();
-
- foreach ($this->query as $k => $v) {
- if (is_array($v) && isset($v['$elemMatch']) && is_array($v['$elemMatch'])) {
- $elemMatchFields = $this->getFieldsFromElemMatch($v['$elemMatch']);
- foreach ($elemMatchFields as $field) {
- $fields[] = $k.'.'.$field;
- }
- } elseif ($this->isOperator($k, array('and', 'or'))) {
- foreach ($v as $q) {
- $test = new self($q);
- $fields = array_merge($fields, $test->getFields());
- }
- } elseif ($k[0] !== '$') {
- $fields[] = $k;
- }
- }
- $fields = array_unique(array_merge($fields, array_keys($this->sort)));
- return $fields;
- }
-
- private function getFieldsFromElemMatch(array $elemMatch)
- {
- $fields = array();
- foreach ($elemMatch as $fieldName => $value) {
- if ($this->isOperator($fieldName, 'where')) {
- continue;
- }
-
- if ($this->isOperator($fieldName, array('and', 'or'))) {
- foreach ($value as $q) {
- $test = new self($q);
- $fields = array_merge($fields, $test->getFields());
- }
- } else {
- $fields[] = $fieldName;
- }
- }
- return $fields;
- }
-
- private function isOperator($fieldName, $operator)
- {
- if ( ! is_array($operator)) {
- $operator = array($operator);
- }
- foreach ($operator as $op) {
- if ($fieldName === '$' . $op) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/lib/Doctrine/ODM/MongoDB/Query/Query.php b/lib/Doctrine/ODM/MongoDB/Query/Query.php
index 8af3741b42..67a37ae32e 100644
--- a/lib/Doctrine/ODM/MongoDB/Query/Query.php
+++ b/lib/Doctrine/ODM/MongoDB/Query/Query.php
@@ -70,13 +70,6 @@ class Query extends \Doctrine\MongoDB\Query\Query
*/
private $primers = array();
- /**
- * Whether or not to require indexes.
- *
- * @var boolean
- */
- private $requireIndexes;
-
/**
* Hints for UnitOfWork behavior.
*
@@ -97,10 +90,9 @@ class Query extends \Doctrine\MongoDB\Query\Query
* @param boolean $hydrate
* @param boolean $refresh
* @param array $primers
- * @param null $requireIndexes deprecated
* @param boolean $readOnly
*/
- public function __construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query = array(), array $options = array(), $hydrate = true, $refresh = false, array $primers = array(), $requireIndexes = null, $readOnly = false)
+ public function __construct(DocumentManager $dm, ClassMetadata $class, Collection $collection, array $query = array(), array $options = array(), $hydrate = true, $refresh = false, array $primers = array(), $readOnly = false)
{
$primers = array_filter($primers);
@@ -117,7 +109,6 @@ public function __construct(DocumentManager $dm, ClassMetadata $class, Collectio
$this->class = $class;
$this->hydrate = $hydrate;
$this->primers = $primers;
- $this->requireIndexes = $requireIndexes;
$this->setReadOnly($readOnly);
$this->setRefresh($refresh);
@@ -188,59 +179,6 @@ public function setRefresh($refresh)
$this->unitOfWorkHints[Query::HINT_REFRESH] = (boolean) $refresh;
}
- /**
- * Gets the fields involved in this query.
- *
- * @return array $fields An array of fields names used in this query.
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public function getFieldsInQuery()
- {
- $query = isset($this->query['query']) ? $this->query['query'] : array();
- $sort = isset($this->query['sort']) ? $this->query['sort'] : array();
-
- $extractor = new FieldExtractor($query, $sort);
- return $extractor->getFields();
- }
-
- /**
- * Check if this query is indexed.
- *
- * @return bool
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public function isIndexed()
- {
- $fields = $this->getFieldsInQuery();
- foreach ($fields as $field) {
- if ( ! $this->collection->isFieldIndexed($field)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Gets an array of the unindexed fields in this query.
- *
- * @return array
- *
- * @deprecated method was deprecated in 1.2 and will be removed in 2.0
- */
- public function getUnindexedFields()
- {
- $unindexedFields = array();
- $fields = $this->getFieldsInQuery();
- foreach ($fields as $field) {
- if ( ! $this->collection->isFieldIndexed($field)) {
- $unindexedFields[] = $field;
- }
- }
- return $unindexedFields;
- }
-
/**
* Execute the query and returns the results.
*
@@ -249,10 +187,6 @@ public function getUnindexedFields()
*/
public function execute()
{
- if ($this->isIndexRequired() && ! $this->isIndexed()) {
- throw MongoDBException::queryNotIndexed($this->class->name, $this->getUnindexedFields());
- }
-
$results = parent::execute();
if ( ! $this->hydrate) {
@@ -330,14 +264,4 @@ protected function prepareCursor(BaseCursor $cursor)
return $cursor;
}
-
- /**
- * Return whether queries on this document should require indexes.
- *
- * @return boolean
- */
- private function isIndexRequired()
- {
- return $this->requireIndexes !== null ? $this->requireIndexes : $this->class->requireIndexes;
- }
}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/GeoSpatialTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/GeoSpatialTest.php
index 2c6f648bb0..e025bab185 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/GeoSpatialTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/GeoSpatialTest.php
@@ -21,14 +21,6 @@ public function testQueries()
), $qb->getQueryArray());
}
- public function testGetFieldsInCoordinatesQuery()
- {
- $qb = $this->dm->createQueryBuilder(__NAMESPACE__.'\City');
- $qb->field('coordinates')->withinBox(41, 41, 72, 72);
- $query = $qb->getQuery();
- $this->assertEquals(array('coordinates'), $query->getFieldsInQuery());
- }
-
public function testGeoSpatial1()
{
$this->dm->getSchemaManager()->ensureDocumentIndexes(__NAMESPACE__.'\City');
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RequireIndexesTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RequireIndexesTest.php
deleted file mode 100644
index 98c864c595..0000000000
--- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RequireIndexesTest.php
+++ /dev/null
@@ -1,321 +0,0 @@
-dm->getSchemaManager()->ensureDocumentIndexes('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- }
-
- public function testGetFieldsInQueryWithSimpleEquals()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('test')->equals('test');
- $query = $qb->getQuery();
- $this->assertEquals(array('test'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryIgnoresWhereOperator()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->where('this.test > 0');
- $qb->addOr($qb->expr()->where('this.ok > 1'));
- $qb->addAnd($qb->expr()->field('username')->equals('jwage'));
- $query = $qb->getQuery();
- $this->assertEquals(array('username'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithElemMatch()
- {
- $date = new \DateTime();
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('flashes')->elemMatch(
- $qb->expr()->field('startDate')->lt($date)->field('endDate')->gte($date)
- );
- $query = $qb->getQuery();
- $this->assertEquals(array(
- 'flashes.startDate',
- 'flashes.endDate'
- ), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithElemMatchAndOr()
- {
- $date = new \DateTime();
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('flashes')->elemMatch(
- $qb->expr()->field('startDate')->lt($date)->field('endDate')->gte($date)->field('startDate')
- ->addOr($qb->expr()->field('something')->equals($date))
-
- ->where('this.id > 0')
- )->addAnd($qb->expr()->field('flashes.id')->equals('foo'));
- $query = $qb->getQuery();
- $this->assertEquals(array(
- 'flashes.startDate',
- 'flashes.endDate',
- 'flashes.something',
- 'flashes.id'
- ), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithOrAndIn()
- {
- $date = new \DateTime();
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->addOr($qb->expr()->field('field1')->in(array(1)));
- $qb->addOr($qb->expr()->field('field2')->in(array(1)));
- $query = $qb->getQuery();
- $this->assertEquals(array('field1', 'field2'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithComplexQuery()
- {
- $date = new \DateTime();
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->addOr($qb->expr()->field('field1')->in(array(1)));
- $qb->addAnd($qb->expr()->field('field2')->equals(1));
- $qb->field('field3')->elemMatch($qb->expr()->field('embedded')->range(1, 2));
- $qb->field('field4')->elemMatch($qb->expr()->addOr($qb->expr()->field('embedded')->equals($date)));
- $qb->field('field5')->equals('test');
- $query = $qb->getQuery();
- $this->assertEquals(array(
- 'field1',
- 'field2',
- 'field3.embedded',
- 'field4.embedded',
- 'field5'
- ), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithIn()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('test')->in(array(1));
- $query = $qb->getQuery();
- $this->assertEquals(array('test'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithNotIn()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('test')->notIn(array(1));
- $query = $qb->getQuery();
- $this->assertEquals(array('test'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithNotEqual()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('test')->notEqual(1);
- $query = $qb->getQuery();
- $this->assertEquals(array('test'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithNot()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('test')->not(1);
- $query = $qb->getQuery();
- $this->assertEquals(array('test'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithReferences()
- {
- $reference = new DoesNotRequireIndexesDocument();
- $reference->id = (string) new \MongoId();
- $this->dm->persist($reference);
-
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('reference')->references($reference);
- $qb->field('simpleReference')->references($reference);
- $query = $qb->getQuery();
- $this->assertEquals(array('reference.$id', 'simpleReference'), $query->getFieldsInQuery());
- }
-
- public function testGetFieldsInQueryWithIncludesReferences()
- {
- $reference = new DoesNotRequireIndexesDocument();
- $reference->id = (string) new \MongoId();
- $this->dm->persist($reference);
-
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument');
- $qb->field('reference')->includesReferenceTo($reference);
- $qb->field('simpleReference')->includesReferenceTo($reference);
- $query = $qb->getQuery();
- $this->assertEquals(array('reference.$id', 'simpleReference'), $query->getFieldsInQuery());
- }
-
- public function testIsIndexedTrue()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('indexed')->equals('test');
- $query = $qb->getQuery();
- $this->assertTrue($query->isIndexed());
- }
-
- public function testIsIndexedFalse()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('notIndexed')->equals('test');
- $query = $qb->getQuery();
- $this->assertFalse($query->isIndexed());
-
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('indexed')->equals('test')
- ->field('notIndexed')->equals('test');
- $query = $qb->getQuery();
- $this->assertFalse($query->isIndexed());
- }
-
- /**
- * @expectedException Doctrine\ODM\MongoDB\MongoDBException
- */
- public function testRequireIndexesThrowsExceptionOnExecute()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('notIndexed')->equals('test');
- $query = $qb->getQuery();
- $query->execute();
- }
-
- public function testRequireIndexesExceptionMessage()
- {
- try {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('notIndexed')->equals('test');
- $query = $qb->getQuery();
- $query->execute();
- } catch (MongoDBException $e) {
- $this->assertEquals('Cannot execute unindexed queries on Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument. Unindexed fields: notIndexed', $e->getMessage());
- }
- }
-
- /**
- * @expectedException Doctrine\ODM\MongoDB\MongoDBException
- */
- public function testForceEnableRequireIndexes()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\DoesNotRequireIndexesDocument')
- ->field('notIndexed')->equals('test')
- ->requireIndexes();
- $query = $qb->getQuery();
- $query->execute();
- }
-
- public function testForceDisableRequireIndexes()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('notIndexed')->equals('test')
- ->requireIndexes(false);
- $query = $qb->getQuery();
- $query->execute();
- }
-
-
- public function testRequireIndexesFalse()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\DoesNotRequireIndexesDocument')
- ->field('notIndexed')->equals('test');
- $query = $qb->getQuery();
- $query->execute();
- }
-
- public function testRequireIndexesOnEmbeddedDocument()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('embedOne.indexed')->equals('test');
- $query = $qb->getQuery();
- $query->execute();
- }
-
- /**
- * @expectedException Doctrine\ODM\MongoDB\MongoDBException
- */
- public function testRequireIndexesOnEmbeddedDocumentThrowsException()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('embedOne.notIndexed')->equals('test');
- $query = $qb->getQuery();
- $query->execute();
- }
-
- /**
- * @expectedException Doctrine\ODM\MongoDB\MongoDBException
- */
- public function testRequireIndexesOnSortThrowException()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->sort('embedOne.notIndexed', 'asc');
- $query = $qb->getQuery();
- $query->execute();
- }
-
- public function testGetUnindexedFields()
- {
- $qb = $this->dm->createQueryBuilder('Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesDocument')
- ->field('embedOne.notIndexed')->equals('test')
- ->field('notIndexed')->equals('test')
- ->field('indexed')->equals('test');
- $query = $qb->getQuery();
- $this->assertEquals(array('embedOne.notIndexed', 'notIndexed'), $query->getUnindexedFields());
- }
-}
-
-/**
- * @ODM\Document(requireIndexes=true)
- */
-class RequireIndexesDocument
-{
- /** @ODM\Id */
- public $id;
-
- /** @ODM\Field(type="string") @ODM\Index */
- public $indexed;
-
- /** @ODM\Field(type="string") */
- public $notIndexed;
-
- /** @ODM\EmbedOne(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesEmbeddedDocument") */
- public $embedOne;
-
- /** @ODM\EmbedMany(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\RequireIndexesEmbeddedDocument") */
- public $embedMany;
-
- /** @ODM\ReferenceOne(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\DoesNotRequireIndexesDocument") */
- public $reference;
-
- /** @ODM\ReferenceOne(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\DoesNotRequireIndexesDocument", simple=true) */
- public $simpleReference;
-}
-
-/**
- * @ODM\Document(requireIndexes=false)
- */
-class DoesNotRequireIndexesDocument
-{
- /** @ODM\Id */
- public $id;
-
- /** @ODM\Field(type="string") @ODM\Index */
- public $indexed;
-
- /** @ODM\Field(type="string") */
- public $notIndexed;
-}
-
-/** @ODM\EmbeddedDocument */
-class RequireIndexesEmbeddedDocument
-{
- /** @ODM\Field(type="string") @ODM\Index */
- public $indexed;
-
- /** @ODM\Field(type="string") */
- public $notIndexed;
-}
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php
index 7453e77dee..aa1ab5f7fc 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/XmlDriverTest.php
@@ -43,7 +43,6 @@ public function testDriverShouldParseNonStringAttributes()
$classMetadata = new ClassMetadata('TestDocuments\UserNonStringOptions');
$this->driver->loadMetadataForClass('TestDocuments\UserNonStringOptions', $classMetadata);
- $this->assertSame(true, $classMetadata->requireIndexes);
$this->assertSame(false, $classMetadata->slaveOkay);
$profileMapping = $classMetadata->fieldMappings['profile'];
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.UserNonStringOptions.dcm.xml b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.UserNonStringOptions.dcm.xml
index 8a3df80da4..eb8f43185f 100644
--- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.UserNonStringOptions.dcm.xml
+++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/fixtures/xml/TestDocuments.UserNonStringOptions.dcm.xml
@@ -1,13 +1,13 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/FieldExtractorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/FieldExtractorTest.php
deleted file mode 100644
index f57629aadd..0000000000
--- a/tests/Doctrine/ODM/MongoDB/Tests/Query/FieldExtractorTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-assertFieldsExtracted($query, $fields);
- }
-
- public function getQueriesAndFields()
- {
- return array(
- array(
- array('fieldName' => 1),
- array('fieldName')
- ),
- array(
- array('fieldName' => array(
- '$elemMatch' => array(
- 'embedded' => 1
- )
- )),
- array('fieldName.embedded')
- ),
- array(
- array('fieldName' => array(
- '$in' => array(1)
- )),
- array('fieldName')
- ),
- array(
- array('fieldName' => array(
- '$gt' => 1
- )),
- array('fieldName')
- ),
- array(
- array('$or' => array(
- array(
- 'fieldName1' => array(
- '$in' => array(1)
- )
- ),
- array(
- 'fieldName2' => array(
- '$in' => array(1)
- )
- ),
- array(
- 'fieldName3' => 1
- )
- )),
- array('fieldName1', 'fieldName2', 'fieldName3')
- ),
- array(
- array('$and' => array(
- array(
- 'fieldName1' => array(
- '$in' => array(1)
- )
- ),
- array(
- 'fieldName2' => array(
- '$in' => array(1)
- )
- ),
- array(
- 'fieldName3' => 1
- )
- )),
- array('fieldName1', 'fieldName2', 'fieldName3')
- )
- );
- }
-
- private function assertFieldsExtracted(array $query, array $fields)
- {
- $extractor = new FieldExtractor($query);
- $this->assertEquals($fields, $extractor->getFields());
- }
-}
\ No newline at end of file