Skip to content

Commit

Permalink
Merge pull request #1474 from malarzm/remove-increment-type
Browse files Browse the repository at this point in the history
[2.0] Remove deprecated increment type
  • Loading branch information
malarzm authored Aug 5, 2016
2 parents 3f195e5 + e74e5c1 commit d477eb4
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 116 deletions.
47 changes: 0 additions & 47 deletions docs/en/reference/annotations-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -726,53 +726,6 @@ via the :ref:`strategy <basic_mapping_identifiers>` attribute.
protected $id;
}
@Increment
----------

The increment type is just like an integer field, except that it will be updated
using the ``$inc`` operator instead of ``$set``:

.. code-block:: php
<?php
class Package
{
/** @Increment */
private $downloads = 0;
public function incrementDownloads()
{
$this->downloads++;
}
// ...
}
Now, update a Package instance like so:

.. code-block:: php
<?php
$package->incrementDownloads();
$dm->flush();
The query sent to Mongo would resemble the following:

.. code-block:: json
{ "$inc": { "downloads": 1 } }
The field will be incremented by the difference between the new and old values.
This is useful if many requests are attempting to update the field concurrently.

.. note::

This annotation is deprecated and will be removed in ODM 2.0. Please use the
`@Field`_ annotation with type "int" or "float" and use the "increment"
strategy.

@Index
------

Expand Down
4 changes: 0 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1264,9 +1264,6 @@ public function mapField(array $mapping)
if (isset($mapping['type']) && $mapping['type'] === 'file') {
$mapping['file'] = true;
}
if (isset($mapping['type']) && $mapping['type'] === 'increment') {
$mapping['strategy'] = self::STORAGE_STRATEGY_INCREMENT;
}
if (isset($mapping['file']) && $mapping['file'] === true) {
$this->file = $mapping['fieldName'];
$mapping['name'] = 'file';
Expand Down Expand Up @@ -1399,7 +1396,6 @@ private function applyStorageStrategy(array &$mapping)
switch (true) {
case $mapping['type'] == 'int':
case $mapping['type'] == 'float':
case $mapping['type'] == 'increment':
$defaultStrategy = self::STORAGE_STRATEGY_SET;
$allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT];
break;
Expand Down
49 changes: 0 additions & 49 deletions lib/Doctrine/ODM/MongoDB/Types/IncrementType.php

This file was deleted.

2 changes: 0 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ abstract class Type
const FILE = 'file';
const HASH = 'hash';
const COLLECTION = 'collection';
const INCREMENT = 'increment';
const OBJECTID = 'object_id';
const RAW = 'raw';

Expand Down Expand Up @@ -82,7 +81,6 @@ abstract class Type
self::FILE => Types\FileType::class,
self::HASH => Types\HashType::class,
self::COLLECTION => Types\CollectionType::class,
self::INCREMENT => Types\IncrementType::class,
self::OBJECTID => Types\ObjectIdType::class,
self::RAW => Types\RawType::class,
);
Expand Down
12 changes: 0 additions & 12 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,6 @@ public function testReferenceManySortMustNotBeUsedWithNonSetCollectionStrategy()
));
}

public function testIncrementTypeAutomaticallyAssumesIncrementStrategy()
{
$cm = new ClassMetadataInfo('stdClass');
$cm->mapField([
'fieldName' => 'incrementField',
'type' => 'increment',
]);

$mapping = $cm->fieldMappings['incrementField'];
$this->assertSame(ClassMetadataInfo::STORAGE_STRATEGY_INCREMENT, $mapping['strategy']);
}

public function testSetShardKeyForClassWithoutInheritance()
{
$cm = new ClassMetadataInfo('stdClass');
Expand Down
2 changes: 0 additions & 2 deletions tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public function provideTypes()
array(Type::getType(Type::FILE), new GridFSFile()),
array(Type::getType(Type::HASH), array('foo' => 'bar')),
array(Type::getType(Type::COLLECTION), array('foo', 'bar')),
array(Type::getType(Type::INCREMENT), 1),
array(Type::getType(Type::INCREMENT), 1.1),
array(Type::getType(Type::OBJECTID), "507f1f77bcf86cd799439011"),
array(Type::getType(Type::RAW), (object) array('foo' => 'bar')),
);
Expand Down

0 comments on commit d477eb4

Please sign in to comment.