Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate index creation options from index options #1910

Merged
merged 5 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

* The `--depth` option in the `odm:query` command was dropped without
replacement.
* The `--timeout` option for all schema commands was dropped. You should use the
`--maxTimeMs` option instead.

## Aggregation builder
* The `debug` method in `Doctrine\ODM\MongoDB\Aggregation\Stage\Match` was dropped
Expand Down Expand Up @@ -111,6 +113,8 @@ are no longer possible:
`dbRefWithDB`. This omits the `$db` key in the `DBRef` object when possible.
This only has implications if you consume documents outside of ODM and require
the `$db` key to be set or if you are using multiple databases to store data.
* The `dropDups` option on indexes has been dropped without replacement since it
is no longer respected by MongoDB.

### YAML mapping

Expand Down
3 changes: 0 additions & 3 deletions docs/en/reference/indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ You can customize the index with some additional options:
**name** - The name of the index. This can be useful if you are
indexing many keys and Mongo complains about the index name being
too long.
-
**dropDups** - If a unique index is being created and duplicate
values exist, drop all but one duplicate value.
-
**background** - Create indexes in the background while other
operations are taking place. By default, index creation happens
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/xml-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ of several common elements:
<field field-name="email" type="string" unique="true" order="desc" />
<field field-name="createdAt" type="date" />
<indexes>
<index unique="true" dropDups="true">
<index unique="true">
<key name="username" order="desc" />
<option name="safe" value="true" />
</index>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ abstract class AbstractIndex extends Annotation
/** @var string */
public $name;

/** @var bool|null */
public $dropDups;

/** @var bool|null */
public $background;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function addIndex(ClassMetadata $class, AbstractIndex $index, array $key
{
$keys = array_merge($keys, $index->keys);
$options = [];
$allowed = ['name', 'dropDups', 'background', 'unique', 'sparse', 'expireAfterSeconds'];
$allowed = ['name', 'background', 'unique', 'sparse', 'expireAfterSeconds'];
foreach ($allowed as $name) {
if (! isset($index->$name)) {
continue;
Expand Down
6 changes: 0 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ private function addFieldMapping(ClassMetadata $class, array $mapping) : void
if (isset($mapping['background'])) {
$options['background'] = (bool) $mapping['background'];
}
if (isset($mapping['drop-dups'])) {
$options['dropDups'] = (bool) $mapping['drop-dups'];
}
if (isset($mapping['index-name'])) {
$options['name'] = (string) $mapping['index-name'];
}
Expand Down Expand Up @@ -424,9 +421,6 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex) : vo
if (isset($attributes['background'])) {
$options['background'] = ((string) $attributes['background'] === 'true');
}
if (isset($attributes['drop-dups'])) {
$options['dropDups'] = ((string) $attributes['drop-dups'] === 'true');
}
if (isset($attributes['name'])) {
$options['name'] = (string) $attributes['name'];
}
Expand Down
Loading