Skip to content

Commit

Permalink
Merge pull request #1926 from alcaeus/fix-wrong-gridfs-attribute-capi…
Browse files Browse the repository at this point in the history
…talisation

Fix wrong capitalisation of attributes for GridFS mappings
  • Loading branch information
alcaeus authored Jan 9, 2019
2 parents 4aff95e + e20bb0e commit 181edb9
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions docs/en/cookbook/mapping-classes-to-orm-and-odm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ Now map the same class to the Doctrine MongoDB ODM:
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<document name="Documents\BlogPost" repository-class="Doctrine\Blog\ODM\MongoDB\BlogPostRepository">
<field fieldName="id" type="id" />
<field fieldName="name" type="string" />
<field fieldName="email" type="text" />
<field field-name="id" type="id" />
<field field-name="name" type="string" />
<field field-name="email" type="text" />
</document>
</doctrine-mongo-mapping>
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/aggregation-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ they can't be persisted to the database.
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<query-result-document name="Documents\UserPurchases">
<field fieldName="numPurchases" type="int" />
<field fieldName="amount" type="float" />
<field field-name="numPurchases" type="int" />
<field field-name="amount" type="float" />
<reference-one field="user" target-document="Documents\User" name="_id" />
</query-result-document>
</doctrine-mongo-mapping>
Expand Down
6 changes: 3 additions & 3 deletions docs/en/reference/basic-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Example:
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<document name="Documents\User">
<id />
<field fieldName="username" type="string" />
<field field-name="username" type="string" />
</document>
</doctrine-mongo-mapping>
Expand All @@ -404,7 +404,7 @@ as follows:
.. code-block:: xml
<field fieldName="name" name="db_name" />
<field field-name="name" name="db_name" />
Custom Mapping Types
--------------------
Expand Down Expand Up @@ -503,7 +503,7 @@ type in your mapping like this:
.. code-block:: xml
<field fieldName="field" type="mytype" />
<field field-name="field" type="mytype" />
Multiple Document Types in a Collection
---------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/capped-collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ the ``@Document`` annotation:
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<document name="Documents\Category" collection="collname" capped-collection="true" capped-collection-size="100000" capped-collection-max="1000">
<id />
<field fieldName="name" type="string" />
<field field-name="name" type="string" />
</document>
</doctrine-mongo-mapping>
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Unique Index
.. code-block:: xml
<field fieldName="username" index="true" unique="true" order="asc" />
<field field-name="username" index="true" unique="true" order="asc" />
For your convenience you can quickly specify a unique index with
``@UniqueIndex``:
Expand All @@ -118,7 +118,7 @@ For your convenience you can quickly specify a unique index with
.. code-block:: xml
<field fieldName="username" unique="true" order="asc" />
<field field-name="username" unique="true" order="asc" />
If you want to specify an index that consists of multiple fields
you can specify them on the class doc block:
Expand Down
8 changes: 4 additions & 4 deletions docs/en/reference/reference-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ omit the ``targetDocument`` option:
.. code-block:: xml
<field fieldName="favorites" />
<field field-name="favorites" />
Now the ``$favorites`` property can store a reference to any type of document!
The class name will be automatically stored in a field named
Expand Down Expand Up @@ -187,7 +187,7 @@ The name of the field within the DBRef object can be customized via the
.. code-block:: xml
<reference-many fieldName="favorites">
<reference-many field-name="favorites">
<discriminator-field name="type" />
</reference-many>
Expand Down Expand Up @@ -220,7 +220,7 @@ in each `DBRef`_ object:
.. code-block:: xml
<reference-many fieldName="favorites">
<reference-many field-name="favorites">
<discriminator-map>
<discriminator-mapping value="album" class="Documents\Album" />
<discriminator-mapping value="song" class="Documents\Song" />
Expand Down Expand Up @@ -257,7 +257,7 @@ a certain class, you can optionally specify a default discriminator value:
.. code-block:: xml
<reference-many fieldName="favorites">
<reference-many field-name="favorites">
<discriminator-map>
<discriminator-mapping value="album" class="Documents\Album" />
<discriminator-mapping value="song" class="Documents\Song" />
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/storing-files-with-mongogridfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ look like this:
<length />
<chunk-size />
<upload-date />
<filename fieldName="name" />
<filename field-name="name" />
<metadata target-document="Documents\ImageMetadata" />
</gridfs-file>
Expand Down
6 changes: 3 additions & 3 deletions docs/en/reference/transactions-and-concurrency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The following example designates a version field using the ``int`` type:
.. code-block:: xml
<field fieldName="version" version="true" type="int" />
<field field-name="version" version="true" type="int" />
Alternatively, the ``date`` type may be used:

Expand All @@ -81,7 +81,7 @@ Alternatively, the ``date`` type may be used:
.. code-block:: xml
<field fieldName="version" version="true" type="date" />
<field field-name="version" version="true" type="date" />
Choosing the Field Type
"""""""""""""""""""""""
Expand Down Expand Up @@ -239,7 +239,7 @@ Pessimistic locking requires a document to designate a lock field using the ``in
.. code-block:: xml
<field fieldName="lock" lock="true" type="int" />
<field field-name="lock" lock="true" type="int" />
Lock Modes
^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/xml-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ This is only compatible with the ``int`` field type.
.. code-block:: xml
<doctrine-mongo-mapping>
<field fieldName="lock" lock="true" type="int" />
<field field-name="lock" lock="true" type="int" />
</doctrine-mongo-mapping>
.. _xml_reference_version:
Expand All @@ -175,7 +175,7 @@ This is only compatible with ``int`` and ``date`` field types.
.. code-block:: xml
<doctrine-mongo-mapping>
<field fieldName="version" version="true" type="int" />
<field field-name="version" version="true" type="int" />
</doctrine-mongo-mapping>
By default, Doctrine ODM updates :ref:`embed-many <embed_many>` and
Expand Down
12 changes: 6 additions & 6 deletions docs/en/tutorials/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ You can provide your mapping information in Annotations or XML:
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<document name="Documents\User">
<id />
<field fieldName="name" type="string" />
<field fieldName="email" type="string" />
<reference-many fieldName="posts" targetDocument="Documents\BlogPost">
<field field-name="name" type="string" />
<field field-name="email" type="string" />
<reference-many field-name="posts" targetDocument="Documents\BlogPost">
<cascade>
<all/>
</cascade>
Expand All @@ -132,9 +132,9 @@ You can provide your mapping information in Annotations or XML:
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<document name="Documents\BlogPost">
<id />
<field fieldName="title" type="string" />
<field fieldName="body" type="string" />
<field fieldName="createdAt" type="date" />
<field field-name="title" type="string" />
<field field-name="body" type="string" />
<field field-name="createdAt" type="date" />
</document>
</doctrine-mongo-mapping>
Expand Down
12 changes: 6 additions & 6 deletions doctrine-mongo-mapping.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<xs:attribute name="db" type="xs:NMTOKEN" />
<xs:attribute name="bucket-name" type="xs:NMTOKEN" default="fs" />
<xs:attribute name="repository-class" type="xs:string" />
<xs:attribute name="writeConcern" type="xs:string" />
<xs:attribute name="write-concern" type="xs:string" />
<xs:attribute name="inheritance-type" type="odm:inheritance-type" />
<xs:attribute name="change-tracking-policy" type="odm:change-tracking-policy" />
<xs:attribute name="chunk-size-bytes" type="xs:positiveInteger" />
Expand Down Expand Up @@ -140,19 +140,19 @@
</xs:complexType>

<xs:complexType name="gridfs-length-field">
<xs:attribute name="fieldName" type="xs:NMTOKEN" default="length" />
<xs:attribute name="field-name" type="xs:NMTOKEN" default="length" />
</xs:complexType>

<xs:complexType name="gridfs-chunk-size-field">
<xs:attribute name="fieldName" type="xs:NMTOKEN" default="chunkSize" />
<xs:attribute name="field-name" type="xs:NMTOKEN" default="chunkSize" />
</xs:complexType>

<xs:complexType name="gridfs-upload-date-field">
<xs:attribute name="fieldName" type="xs:NMTOKEN" default="uploadDate" />
<xs:attribute name="field-name" type="xs:NMTOKEN" default="uploadDate" />
</xs:complexType>

<xs:complexType name="gridfs-filename-field">
<xs:attribute name="fieldName" type="xs:NMTOKEN" default="filename" />
<xs:attribute name="field-name" type="xs:NMTOKEN" default="filename" />
</xs:complexType>

<xs:complexType name="gridfs-metadata-field">
Expand All @@ -163,7 +163,7 @@
</xs:choice>

<xs:attribute name="target-document" type="xs:string" use="required" />
<xs:attribute name="fieldName" type="xs:NMTOKEN" />
<xs:attribute name="field-name" type="xs:NMTOKEN" />
</xs:complexType>

<xs:complexType name="embed-one">
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ private function addGridFSMappings(ClassMetadata $class, SimpleXMLElement $xmlRo
continue;
}

if (isset($xmlRoot->{$name}->attributes()['fieldName'])) {
$mapping['fieldName'] = (string) $xmlRoot->{$name}->attributes()['fieldName'];
if (isset($xmlRoot->{$name}->attributes()['field-name'])) {
$mapping['fieldName'] = (string) $xmlRoot->{$name}->attributes()['field-name'];
}

$this->addFieldMapping($class, $mapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

<gridfs-file name="Doctrine\ODM\MongoDB\Tests\Mapping\AbstractMappingDriverFile" chunk-size-bytes="12345">
<id />
<length fieldName="size" />
<length field-name="size" />
<chunk-size />
<upload-date />
<filename fieldName="name" />
<filename field-name="name" />

<metadata target-document="Doctrine\ODM\MongoDB\Tests\Mapping\AbstractMappingDriverFileMetadata" />
</gridfs-file>
Expand Down

0 comments on commit 181edb9

Please sign in to comment.