Skip to content

Commit

Permalink
Deprecate dropDups option on indexes (doctrine#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Jan 11, 2019
1 parent 6b18ed7 commit 3f37f79
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions UPGRADE-1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in
* Using more than one class-level document annotation (e.g. `@Document`,
`@MappedSuperclass`) is deprecated and will throw an exception in 2.0.
Classes should only be annotated with a single document annotation.
* The `dropDups` option on the `@Index` annotation was deprecated and will be
dropped without replacement in 2.0. This functionality is no longer
available.

### XML mappings

* The `writeConcern` attribute in document mappings has been deprecated and
will be dropped in 2.0. Use `write-concern` instead.
* The `fieldName` attribute in field mappings has been deprecated and will be
dropped in 2.0. Use `field-name` instead.
* The `drop-dups` attribute in the `index` element was deprecated and will be
dropped without replacement in 2.0. This functionality is no longer
available.

### Full discriminator maps required

Expand Down
3 changes: 2 additions & 1 deletion docs/en/reference/indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ You can customize the index with some additional options:
too long.
-
**dropDups** - If a unique index is being created and duplicate
values exist, drop all but one duplicate value.
values exist, drop all but one duplicate value. This option is deprecated and
will be dropped without replacement in 2.0.
-
**background** - Create indexes in the background while other
operations are taking place. By default, index creation happens
Expand Down
1 change: 1 addition & 0 deletions doctrine-mongo-mapping.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
<xs:element name="partial-filter-expression" type="odm:partial-filter-expression" minOccurs="0" maxOccurs="1"/>
</xs:choice>
<xs:attribute name="name" type="xs:NMTOKEN"/>
<!-- deprecated -->
<xs:attribute name="drop-dups" type="xs:boolean"/>
<xs:attribute name="background" type="xs:boolean"/>
<xs:attribute name="safe" type="xs:boolean"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ abstract class AbstractIndex extends Annotation
{
public $keys = array();
public $name;
/** @deprecated */
public $dropDups;
public $background;
public $safe;
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,10 @@ public function setSlaveOkay($slaveOkay)
*/
public function addIndex($keys, array $options = array())
{
if (isset($options['dropDups'])) {
@trigger_error(sprintf('Ths "dropDups" option on indexes is deprecated and will be dropped in 2.0. Remove the "dropDups" options in class "%s".', $this->getName()), E_USER_DEPRECATED);
}

$this->indexes[] = array(
'keys' => array_map(function($value) {
if ($value == 1 || $value == -1) {
Expand Down

0 comments on commit 3f37f79

Please sign in to comment.