Skip to content
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
3 changes: 3 additions & 0 deletions UPGRADE-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ the `Doctrine\ODM\MongoDB\Id\IdGenerator` interface.

The `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` class has been marked final. The class will no longer be extendable
in ODM 3.0.

The `boolean` and `integer` mapping types have been deprecated. Use their shorthand counterparts: `bool` and `int`
respectively.
2 changes: 1 addition & 1 deletion docs/en/cookbook/blending-orm-and-mongodb-odm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Next create the ``Order`` entity that has a ``$product`` and ``$productId`` prop
class Order
{
/**
* @Id @Column(type="integer")
* @Id @Column(type="int")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
Expand Down
4 changes: 2 additions & 2 deletions docs/en/cookbook/mapping-classes-to-orm-and-odm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ First define the mapping for the ORM:
/** @Entity(repositoryClass=BlogPostRepository::class) */
class BlogPost
{
/** @Id @Column(type="integer") */
/** @Id @Column(type="int") */
private $id;

/** @Column(type="string") */
Expand All @@ -73,7 +73,7 @@ First define the mapping for the ORM:
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Documents\Blog\BlogPost" repository-class="Documents\Blog\Repository\ORM\BlogPostRepository">
<id name="id" type="integer" />
<id name="id" type="int" />
<field name="name" type="string" />
<field name="email" type="text" />
</entity>
Expand Down
13 changes: 13 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use function sprintf;
use function strtolower;
use function strtoupper;
use function trigger_error;

/**
* A <tt>ClassMetadata</tt> instance holds all the object-document mapping metadata
Expand Down Expand Up @@ -1983,6 +1984,18 @@ public function mapField(array $mapping) : array
$this->checkDuplicateMapping($mapping);
$this->typeRequirementsAreMet($mapping);

$deprecatedTypes = [
Type::BOOLEAN => Type::BOOL,
Type::INTEGER => Type::INT,
];
if (isset($deprecatedTypes[$mapping['type']])) {
@trigger_error(sprintf(
'"%s" type was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use "%s" instead.',
$mapping['type'],
$deprecatedTypes[$mapping['type']]
));
}

$this->fieldMappings[$mapping['fieldName']] = $mapping;
if (isset($mapping['association'])) {
$this->associationMappings[$mapping['fieldName']] = $mapping;
Expand Down
14 changes: 8 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
*/
abstract class Type
{
public const ID = 'id';
public const INTID = 'int_id';
public const CUSTOMID = 'custom_id';
public const BOOL = 'bool';
public const BOOLEAN = 'boolean';
public const INT = 'int';
public const ID = 'id';
public const INTID = 'int_id';
public const CUSTOMID = 'custom_id';
public const BOOL = 'bool';
/** @deprecated const was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use Type::BOOL instead */
public const BOOLEAN = 'boolean';
public const INT = 'int';
/** @deprecated const was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use Type::INT instead */
public const INTEGER = 'integer';
public const FLOAT = 'float';
public const STRING = 'string';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class PartialIndexOnDocumentTest
/** @ODM\Field(type="string") */
public $email;

/** @ODM\Field(type="integer") */
/** @ODM\Field(type="int") */
public $counter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function testDriver()
$this->assertEquals([
'fieldName' => 'count',
'name' => 'count',
'type' => 'integer',
'type' => 'int',
'isCascadeDetach' => false,
'isCascadeMerge' => false,
'isCascadePersist' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<query-result-document name="TestDocuments\QueryResultDocument">
<field name="name" type="string" />
<field name="count" type="integer" />
<field name="count" type="int" />
</query-result-document>

</doctrine-mongo-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<view name="TestDocuments\View">
<field name="name" type="string" />
<field name="count" type="integer" />
<field name="count" type="int" />
</view>

</doctrine-mongo-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<field field-name="lock" lock="true" type="int" />
<field field-name="name" name="username" type="string" />
<field field-name="email" type="string" unique="true" drop-dups="true" order="desc" />
<field field-name="mysqlProfileId" type="integer" unique="true" drop-dups="true" order="desc" />
<field field-name="mysqlProfileId" type="int" unique="true" drop-dups="true" order="desc" />
<field field-name="createdAt" type="date" />
<field field-name="roles" type="collection" />
<indexes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ShardedByScalars
/** @ODM\Field(type="string") */
public $string;

/** @ODM\Field(type="boolean") */
/** @ODM\Field(type="bool") */
public $bool;

/** @ODM\Field(type="float") */
Expand Down