mirror of
https://github.com/doctrine/orm.git
synced 2026-04-23 06:28:08 +02:00
Compare commits
115 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 434820973c | |||
| 41ff526921 | |||
| 0be52b0087 | |||
| ee8dc496d9 | |||
| f80656cddf | |||
| 72121c01ec | |||
| ac505390dd | |||
| 728e6e15c5 | |||
| d21305378c | |||
| 0552749059 | |||
| fbd3fe95e4 | |||
| c6d02daee0 | |||
| 5208035003 | |||
| d93956eff0 | |||
| b3b06d3e7d | |||
| 427f815975 | |||
| bf601ce268 | |||
| 8bfb363fcc | |||
| ebf2630a66 | |||
| 9018955e1f | |||
| 88d58ae0a3 | |||
| 2fc99afd44 | |||
| fa0885e25d | |||
| 0e4a0108d2 | |||
| 58370256c0 | |||
| d5364231c2 | |||
| 4df3a4d436 | |||
| 812989490c | |||
| 892ef9edb7 | |||
| 982782f8c9 | |||
| 7319f524a3 | |||
| 1d71fbf77b | |||
| 7eacfec2c3 | |||
| 46f2a41cf7 | |||
| fd2baf6f65 | |||
| c8bf06d549 | |||
| 3acfa50214 | |||
| 3dbe205498 | |||
| 899cce8094 | |||
| 7400d51444 | |||
| 96c344d22b | |||
| f48d71ecd0 | |||
| d3acbbf79b | |||
| cb9ec8234b | |||
| 47c72e583e | |||
| 568c2d308c | |||
| 11a7f359d1 | |||
| 145f1f5198 | |||
| ff1df41485 | |||
| d36aec8fb7 | |||
| 2779b5ee91 | |||
| 32efbd3edd | |||
| 68718eac1b | |||
| 7b64b4a207 | |||
| f1143f591f | |||
| 07fc401d25 | |||
| 96f166a7e9 | |||
| f4b775323d | |||
| 43d308116d | |||
| d2b4dd71d2 | |||
| 36e6a73d5b | |||
| e26158a45e | |||
| 3cfcd6a856 | |||
| ff68806bfa | |||
| 4192c3abf4 | |||
| ac1e1c7d23 | |||
| 9ab999618c | |||
| f2666a472f | |||
| ceda5d3bc7 | |||
| 6d81d519b6 | |||
| 88d1d79516 | |||
| cfc6cfd1a3 | |||
| 6b7d67b427 | |||
| b6d08b15c0 | |||
| 01f89a8cdc | |||
| efd7a5dca6 | |||
| 7ba0290643 | |||
| 8ceb47178b | |||
| 2560d4f419 | |||
| 87ee409783 | |||
| d47c1f3e9b | |||
| b952dac339 | |||
| ffb7d4c79c | |||
| e68717b725 | |||
| 30a063ef9d | |||
| 35c3669ebc | |||
| 23f4f03575 | |||
| a912fc09be | |||
| a736a3713b | |||
| f2da5bc93e | |||
| 2905b435db | |||
| 48ca6dbcec | |||
| 15a4302902 | |||
| 1f82a20312 | |||
| fc943b70f6 | |||
| f36470941c | |||
| ae6d80daab | |||
| 44e82e2720 | |||
| e94467d6da | |||
| 794c7708e8 | |||
| 8e73926359 | |||
| 8fc1d74820 | |||
| 496c6a9f03 | |||
| 7873f700b0 | |||
| 46c0861f45 | |||
| 5149c0ff25 | |||
| cf99d62472 | |||
| 5878797eae | |||
| 8c2d090dc8 | |||
| 3f772eac32 | |||
| 62c952d258 | |||
| c2f698e56e | |||
| 40f2a3efba | |||
| 333b9c0b99 | |||
| 90d19b4131 |
@@ -5,6 +5,7 @@ language: php
|
||||
php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- nightly
|
||||
|
||||
env:
|
||||
@@ -57,6 +58,7 @@ jobs:
|
||||
|
||||
- stage: Test
|
||||
if: type = cron
|
||||
php: 7.3
|
||||
env: DB=sqlite DEV_DEPENDENCIES
|
||||
install:
|
||||
- composer config minimum-stability dev
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Upgrade to 2.6
|
||||
|
||||
## Added `Doctrine\ORM\EntityRepository::count()` method
|
||||
|
||||
`Doctrine\ORM\EntityRepository::count()` has been added. This new method has different
|
||||
signature than `Countable::count()` (required parameter) and therefore are not compatible.
|
||||
If your repository implemented the `Countable` interface, you will have to use
|
||||
`$repository->count([])` instead and not implement `Countable` interface anymore.
|
||||
|
||||
## Minor BC BREAK: `Doctrine\ORM\Tools\Console\ConsoleRunner` is now final
|
||||
|
||||
Since it's just an utilitarian class and should not be inherited.
|
||||
|
||||
@@ -322,7 +322,7 @@ The aggregate field ``Account::$balance`` is now -200, however the
|
||||
SUM over all entries amounts yields -400. A violation of our max
|
||||
credit rule.
|
||||
|
||||
You can use both optimistic or pessimistic locking to save-guard
|
||||
You can use both optimistic or pessimistic locking to safe-guard
|
||||
your aggregate fields against this kind of race-conditions. Reading
|
||||
Eric Evans DDD carefully he mentions that the "Aggregate Root"
|
||||
(Account in our example) needs a locking mechanism.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Working with DateTime Instances
|
||||
===============================
|
||||
|
||||
There are many nitty gritty details when working with PHPs DateTime instances. You have know their inner
|
||||
There are many nitty gritty details when working with PHPs DateTime instances. You have to know their inner
|
||||
workings pretty well not to make mistakes with date handling. This cookbook entry holds several
|
||||
interesting pieces of information on how to work with PHP DateTime instances in Doctrine 2.
|
||||
|
||||
|
||||
@@ -313,8 +313,8 @@ One-To-Many, Bidirectional
|
||||
--------------------------
|
||||
|
||||
A one-to-many association has to be bidirectional, unless you are using a
|
||||
join table. This is because the many side in a one-to-many association holds
|
||||
the foreign key, making it the owning side. Doctrine needs the many side
|
||||
join table. This is because the "many" side in a one-to-many association holds
|
||||
the foreign key, making it the owning side. Doctrine needs the "many" side
|
||||
defined in order to understand the association.
|
||||
|
||||
This bidirectional mapping requires the ``mappedBy`` attribute on the
|
||||
@@ -335,7 +335,7 @@ bidirectional many-to-one.
|
||||
{
|
||||
// ...
|
||||
/**
|
||||
* One Product has Many Features.
|
||||
* One product has many features. This is the inverse side.
|
||||
* @OneToMany(targetEntity="Feature", mappedBy="product")
|
||||
*/
|
||||
private $features;
|
||||
@@ -351,7 +351,7 @@ bidirectional many-to-one.
|
||||
{
|
||||
// ...
|
||||
/**
|
||||
* Many Features have One Product.
|
||||
* Many features have one product. This is the owning side.
|
||||
* @ManyToOne(targetEntity="Product", inversedBy="features")
|
||||
* @JoinColumn(name="product_id", referencedColumnName="id")
|
||||
*/
|
||||
|
||||
@@ -323,7 +323,7 @@ XML would look something like this:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
/Users/robo/dev/php/Doctrine/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="User">
|
||||
|
||||
|
||||
@@ -21,12 +21,6 @@ created database tables and columns.
|
||||
Entity Classes
|
||||
--------------
|
||||
|
||||
I access a variable and its null, what is wrong?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If this variable is a public variable then you are violating one of the criteria for entities.
|
||||
All properties have to be protected or private for the proxy object pattern to work.
|
||||
|
||||
How can I add default values to a column?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -493,7 +493,7 @@ Could be used by an entity that extends a mapped superclass to override a field
|
||||
* column=@Column(
|
||||
* name = "guest_id",
|
||||
* type = "integer",
|
||||
length = 140
|
||||
* length = 140
|
||||
* )
|
||||
* ),
|
||||
* @AttributeOverride(name="name",
|
||||
@@ -501,7 +501,7 @@ Could be used by an entity that extends a mapped superclass to override a field
|
||||
* name = "guest_name",
|
||||
* nullable = false,
|
||||
* unique = true,
|
||||
length = 240
|
||||
* length = 240
|
||||
* )
|
||||
* )
|
||||
* })
|
||||
|
||||
@@ -63,7 +63,7 @@ Where the ``attribute_name`` column contains the key and
|
||||
``$attributes``.
|
||||
|
||||
The feature request for persistence of primitive value arrays
|
||||
`is described in the DDC-298 ticket <http://www.doctrine-project.org/jira/browse/DDC-298>`_.
|
||||
`is described in the DDC-298 ticket <https://github.com/doctrine/doctrine2/issues/3743>`_.
|
||||
|
||||
Cascade Merge with Bi-directional Associations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -71,8 +71,8 @@ Cascade Merge with Bi-directional Associations
|
||||
There are two bugs now that concern the use of cascade merge in combination with bi-directional associations.
|
||||
Make sure to study the behavior of cascade merge if you are using it:
|
||||
|
||||
- `DDC-875 <http://www.doctrine-project.org/jira/browse/DDC-875>`_ Merge can sometimes add the same entity twice into a collection
|
||||
- `DDC-763 <http://www.doctrine-project.org/jira/browse/DDC-763>`_ Cascade merge on associated entities can insert too many rows through "Persistence by Reachability"
|
||||
- `DDC-875 <https://github.com/doctrine/doctrine2/issues/5398>`_ Merge can sometimes add the same entity twice into a collection
|
||||
- `DDC-763 <https://github.com/doctrine/doctrine2/issues/5277>`_ Cascade merge on associated entities can insert too many rows through "Persistence by Reachability"
|
||||
|
||||
Custom Persisters
|
||||
~~~~~~~~~~~~~~~~~
|
||||
@@ -83,8 +83,8 @@ Currently there is no way to overwrite the persister implementation
|
||||
for a given entity, however there are several use-cases that can
|
||||
benefit from custom persister implementations:
|
||||
|
||||
- `Add Upsert Support <http://www.doctrine-project.org/jira/browse/DDC-668>`_
|
||||
- `Evaluate possible ways in which stored-procedures can be used <http://www.doctrine-project.org/jira/browse/DDC-445>`_
|
||||
- `Add Upsert Support <https://github.com/doctrine/doctrine2/issues/5178>`_
|
||||
- `Evaluate possible ways in which stored-procedures can be used <https://github.com/doctrine/doctrine2/issues/4946>`_
|
||||
|
||||
Persist Keys of Collections
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -94,7 +94,7 @@ PHP Arrays are ordered hash-maps and so should be the
|
||||
evaluate a feature that optionally persists and hydrates the keys
|
||||
of a Collection instance.
|
||||
|
||||
`Ticket DDC-213 <http://www.doctrine-project.org/jira/browse/DDC-213>`_
|
||||
`Ticket DDC-213 <https://github.com/doctrine/doctrine2/issues/2817>`_
|
||||
|
||||
Mapping many tables to one entity
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -144,9 +144,8 @@ backwards compatibility issues or where no simple fix exists (yet).
|
||||
We don't plan to add every bug in the tracker there, just those
|
||||
issues that can potentially cause nightmares or pain of any sort.
|
||||
|
||||
See the Open Bugs on Jira for more details on `bugs, improvement and feature
|
||||
requests
|
||||
<http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&mode=hide&pid=10032&resolution=-1&sorter/field=updated&sorter/order=DESC>`_.
|
||||
See bugs, improvement and feature requests on `Github issues
|
||||
<https://github.com/doctrine/doctrine2/issues>`_.
|
||||
|
||||
Identifier Quoting and Legacy Databases
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -310,7 +310,7 @@ Entity cache definition
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Country">
|
||||
<cache usage="READ_ONLY" region="my_entity_region" />
|
||||
<id name="id" type="integer" column="id">
|
||||
@@ -386,7 +386,7 @@ It caches the primary keys of association and cache each element will be cached
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="State">
|
||||
|
||||
<cache usage="NONSTRICT_READ_WRITE" />
|
||||
|
||||
@@ -15,7 +15,7 @@ with associations in Doctrine:
|
||||
removed, not the entity itself. A collection of entities always
|
||||
only represents the association to the containing entities, not the
|
||||
entity itself.
|
||||
- When a bidirectional assocation is updated, Doctrine only checks
|
||||
- When a bidirectional association is updated, Doctrine only checks
|
||||
on one of both sides for these changes. This is called the :doc:`owning side <unitofwork-associations>`
|
||||
of the association.
|
||||
- A property with a reference to many entities has to be instances of the
|
||||
|
||||
@@ -25,6 +25,13 @@ Work that have not yet been persisted are lost.
|
||||
Not calling ``EntityManager#flush()`` will lead to all changes
|
||||
during that request being lost.
|
||||
|
||||
.. note::
|
||||
|
||||
Doctrine does NEVER touch the public API of methods in your entity
|
||||
classes (like getters and setters) nor the constructor method.
|
||||
Instead, it uses reflection to get/set data from/to your entity objects.
|
||||
When Doctrine fetches data from DB and saves it back,
|
||||
any code put in your get/set methods won't be implicitly taken into account.
|
||||
|
||||
Entities and the Identity Map
|
||||
-----------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@ form of XML documents.
|
||||
The XML driver is backed by an XML Schema document that describes
|
||||
the structure of a mapping document. The most recent version of the
|
||||
XML Schema document is available online at
|
||||
`http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd <http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd>`_.
|
||||
`https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd <https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd>`_.
|
||||
In order to point to the latest version of the document of a
|
||||
particular stable release branch, just append the release number,
|
||||
i.e.: doctrine-mapping-2.0.xsd The most convenient way to work with
|
||||
@@ -21,7 +21,7 @@ setup for the latest code in trunk.
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
...
|
||||
|
||||
@@ -107,7 +107,7 @@ of several common elements:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\ORM\Mapping\User" table="cms_users">
|
||||
|
||||
@@ -768,7 +768,7 @@ entity relationship. You can define this in XML with the "association-key" attri
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Application\Model\ArticleAttribute">
|
||||
<id name="article" association-key="true" />
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
YAML Mapping
|
||||
============
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
The YAML mapping driver enables you to provide the ORM metadata in
|
||||
form of YAML documents.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ and year of production as primary keys:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="VehicleCatalogue\Model\Car">
|
||||
<id field="name" type="string" />
|
||||
@@ -203,7 +203,7 @@ We keep up the example of an Article with arbitrary attributes, the mapping look
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Application\Model\ArticleAttribute">
|
||||
<id name="article" association-key="true" />
|
||||
|
||||
@@ -65,7 +65,7 @@ switch to extra lazy as shown in these examples:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\CMS\CmsGroup">
|
||||
<!-- ... -->
|
||||
|
||||
@@ -25,7 +25,7 @@ The code of this tutorial is `available on Github <https://github.com/doctrine/d
|
||||
|
||||
.. note::
|
||||
|
||||
This tutorial assumes you work with **Doctrine 2.4** and above.
|
||||
This tutorial assumes you work with **Doctrine 2.6** and above.
|
||||
Some of the code will not work with lower versions.
|
||||
|
||||
What is Doctrine?
|
||||
@@ -80,14 +80,14 @@ Project Setup
|
||||
-------------
|
||||
|
||||
Create a new empty folder for this tutorial project, for example
|
||||
``doctrine2-tutorial`` and create a new file ``composer.json`` with
|
||||
the following contents:
|
||||
``doctrine2-tutorial`` and create a new file ``composer.json`` inside
|
||||
that directory with the following contents:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"require": {
|
||||
"doctrine/orm": "2.4.*",
|
||||
"doctrine/orm": "^2.6.2",
|
||||
"symfony/yaml": "2.*"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -103,18 +103,21 @@ Install Doctrine using the Composer Dependency Management tool, by calling:
|
||||
$ composer install
|
||||
|
||||
This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM,
|
||||
Symfony YAML and Symfony Console into the `vendor` directory. The Symfony
|
||||
dependencies are not required by Doctrine but will be used in this tutorial.
|
||||
into the ``vendor`` directory.
|
||||
|
||||
Add the following directories:
|
||||
::
|
||||
|
||||
doctrine2-tutorial
|
||||
|-- config
|
||||
| |-- xml
|
||||
| `-- xml
|
||||
| `-- yaml
|
||||
`-- src
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
Obtaining the EntityManager
|
||||
---------------------------
|
||||
|
||||
@@ -150,7 +153,11 @@ step:
|
||||
// obtaining the entity manager
|
||||
$entityManager = EntityManager::create($conn, $config);
|
||||
|
||||
The require_once statement sets up the class autoloading for Doctrine and
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
The ``require_once`` statement sets up the class autoloading for Doctrine and
|
||||
its dependencies using Composer's autoloader.
|
||||
|
||||
The second block consists of the instantiation of the ORM
|
||||
@@ -173,7 +180,7 @@ Generating the Database Schema
|
||||
Doctrine has a command-line interface that allows you to access the SchemaTool,
|
||||
a component that can generate a relational database schema based entirely on the
|
||||
defined entity classes and their metadata. For this tool to work, a
|
||||
cli-config.php file must exist in the project root directory:
|
||||
``cli-config.php`` file must exist in the project root directory:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
@@ -183,20 +190,19 @@ cli-config.php file must exist in the project root directory:
|
||||
|
||||
return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
|
||||
|
||||
Change into your project directory and call the Doctrine command-line tool:
|
||||
Now call the Doctrine command-line tool:
|
||||
|
||||
::
|
||||
|
||||
$ cd project/
|
||||
$ vendor/bin/doctrine orm:schema-tool:create
|
||||
|
||||
Since we haven't added any entity metadata in `src` yet, you'll see a message
|
||||
Since we haven't added any entity metadata in ``src`` yet, you'll see a message
|
||||
stating "No Metadata Classes to process." In the next section, we'll create a
|
||||
Product entity along with the corresponding metadata, and run this command again.
|
||||
|
||||
Note that as you modify your entities' metadata during the development process,
|
||||
you'll need to update your database schema to stay in sync with the metadata.
|
||||
You can rasily recreate the database using the following commands:
|
||||
You can easily recreate the database using the following commands:
|
||||
|
||||
::
|
||||
|
||||
@@ -209,8 +215,8 @@ Or you can use the update functionality:
|
||||
|
||||
$ vendor/bin/doctrine orm:schema-tool:update --force
|
||||
|
||||
The updating of databases uses a Diff Algorithm for a given
|
||||
Database Schema. This is a cornerstone of the ``Doctrine\DBAL`` package,
|
||||
The updating of databases uses a diff algorithm for a given
|
||||
database schema. This is a cornerstone of the ``Doctrine\DBAL`` package,
|
||||
which can even be used without the Doctrine ORM package.
|
||||
|
||||
Starting with the Product Entity
|
||||
@@ -250,16 +256,16 @@ entity definition:
|
||||
}
|
||||
}
|
||||
|
||||
When creating entity classes, all of the fields should be protected or private
|
||||
(not public), with getter and setter methods for each one (except $id).
|
||||
When creating entity classes, all of the fields should be ``protected`` or ``private``
|
||||
(not ``public``), with getter and setter methods for each one (except ``$id``).
|
||||
The use of mutators allows Doctrine to hook into calls which
|
||||
manipulate the entities in ways that it could not if you just
|
||||
manipulate the entities in ways that it could not if you just
|
||||
directly set the values with ``entity#field = foo;``
|
||||
|
||||
The id field has no setter since, generally speaking, your code
|
||||
should not set this value since it represents a database id value.
|
||||
(Note that Doctrine itself can still set the value using the
|
||||
Reflection API instead of a defined setter function)
|
||||
The id field has no setter since, generally speaking, your code
|
||||
should not set this value since it represents a database id value.
|
||||
(Note that Doctrine itself can still set the value using the
|
||||
Reflection API instead of a defined setter function.)
|
||||
|
||||
The next step for persistence with Doctrine is to describe the
|
||||
structure of the ``Product`` entity to Doctrine using a metadata
|
||||
@@ -297,7 +303,7 @@ but you only need to choose one.
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Product" table="products">
|
||||
<id name="id" type="integer">
|
||||
@@ -308,6 +314,10 @@ but you only need to choose one.
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# config/yaml/Product.dcm.yml
|
||||
@@ -323,8 +333,8 @@ but you only need to choose one.
|
||||
name:
|
||||
type: string
|
||||
|
||||
The top-level ``entity`` definition tag specifies information about
|
||||
the class and table-name. The primitive type ``Product#name`` is
|
||||
The top-level ``entity`` definition specifies information about
|
||||
the class and table name. The primitive type ``Product#name`` is
|
||||
defined as a ``field`` attribute. The ``id`` property is defined with
|
||||
the ``id`` tag. It has a ``generator`` tag nested inside, which
|
||||
specifies that the primary key generation mechanism should automatically
|
||||
@@ -833,7 +843,7 @@ the ``Product`` before:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Bug" table="bugs">
|
||||
<id name="id" type="integer">
|
||||
@@ -851,6 +861,10 @@ the ``Product`` before:
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# config/yaml/Bug.dcm.yml
|
||||
@@ -949,7 +963,7 @@ Finally, we'll add metadata mappings for the ``User`` entity.
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="User" table="users">
|
||||
<id name="id" type="integer">
|
||||
@@ -963,6 +977,10 @@ Finally, we'll add metadata mappings for the ``User`` entity.
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# config/yaml/User.dcm.yml
|
||||
@@ -1486,13 +1504,17 @@ we have to adjust the metadata slightly.
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Bug" table="bugs" repository-class="BugRepository">
|
||||
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
|
||||
.. note::
|
||||
The YAML driver is deprecated and will be removed in version 3.0.
|
||||
It is strongly recommended to switch to one of the other mappings.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
Bug:
|
||||
|
||||
@@ -107,7 +107,7 @@ The code and mappings for the Market entity looks like this:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\StockExchange\Market">
|
||||
<id name="id" type="integer">
|
||||
@@ -193,7 +193,7 @@ here are the code and mappings for it:
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\StockExchange\Stock">
|
||||
<id name="id" type="integer">
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
|
||||
namespace Doctrine\ORM;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
use Doctrine\Common\Util\ClassUtils;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Doctrine\ORM\Cache\QueryCacheKey;
|
||||
use Doctrine\DBAL\Cache\QueryCacheProfile;
|
||||
@@ -98,7 +100,7 @@ abstract class AbstractQuery
|
||||
/**
|
||||
* The hydration mode.
|
||||
*
|
||||
* @var integer
|
||||
* @var string|int
|
||||
*/
|
||||
protected $_hydrationMode = self::HYDRATE_OBJECT;
|
||||
|
||||
@@ -410,16 +412,24 @@ abstract class AbstractQuery
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
|
||||
if ($value instanceof Mapping\ClassMetadata) {
|
||||
return $value->name;
|
||||
}
|
||||
|
||||
if (! is_object($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
try {
|
||||
$value = $this->_em->getUnitOfWork()->getSingleIdentifierValue($value);
|
||||
|
||||
if ($value === null) {
|
||||
throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
|
||||
}
|
||||
}
|
||||
|
||||
if ($value instanceof Mapping\ClassMetadata) {
|
||||
return $value->name;
|
||||
} catch (MappingException | ORMMappingException $e) {
|
||||
// Silence any mapping exceptions. These can occur if the object in
|
||||
// question is not a mapped entity, in which case we just don't do
|
||||
// any preparation on the value.
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -680,8 +690,8 @@ abstract class AbstractQuery
|
||||
/**
|
||||
* Defines the processing mode to be used during hydration / result set transformation.
|
||||
*
|
||||
* @param integer $hydrationMode Doctrine processing mode to be used during hydration process.
|
||||
* One of the Query::HYDRATE_* constants.
|
||||
* @param string|int $hydrationMode Doctrine processing mode to be used during hydration process.
|
||||
* One of the Query::HYDRATE_* constants.
|
||||
*
|
||||
* @return static This query instance.
|
||||
*/
|
||||
@@ -695,7 +705,7 @@ abstract class AbstractQuery
|
||||
/**
|
||||
* Gets the hydration mode currently used by the query.
|
||||
*
|
||||
* @return integer
|
||||
* @return string|int
|
||||
*/
|
||||
public function getHydrationMode()
|
||||
{
|
||||
@@ -707,7 +717,7 @@ abstract class AbstractQuery
|
||||
*
|
||||
* Alias for execute(null, $hydrationMode = HYDRATE_OBJECT).
|
||||
*
|
||||
* @param int $hydrationMode
|
||||
* @param string|int $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -743,7 +753,7 @@ abstract class AbstractQuery
|
||||
/**
|
||||
* Get exactly one result or null.
|
||||
*
|
||||
* @param int $hydrationMode
|
||||
* @param string|int $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -781,7 +791,7 @@ abstract class AbstractQuery
|
||||
* If the result is not unique, a NonUniqueResultException is thrown.
|
||||
* If there is no result, a NoResultException is thrown.
|
||||
*
|
||||
* @param integer $hydrationMode
|
||||
* @param string|int $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -875,7 +885,7 @@ abstract class AbstractQuery
|
||||
* iterate over the result.
|
||||
*
|
||||
* @param ArrayCollection|array|null $parameters The query parameters.
|
||||
* @param integer|null $hydrationMode The hydration mode to use.
|
||||
* @param string|int|null $hydrationMode The hydration mode to use.
|
||||
*
|
||||
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
||||
*/
|
||||
@@ -899,7 +909,7 @@ abstract class AbstractQuery
|
||||
* Executes the query.
|
||||
*
|
||||
* @param ArrayCollection|array|null $parameters Query parameters.
|
||||
* @param integer|null $hydrationMode Processing mode to be used during the hydration process.
|
||||
* @param string|int|null $hydrationMode Processing mode to be used during the hydration process.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -916,7 +926,7 @@ abstract class AbstractQuery
|
||||
* Execute query ignoring second level cache.
|
||||
*
|
||||
* @param ArrayCollection|array|null $parameters
|
||||
* @param integer|null $hydrationMode
|
||||
* @param string|int|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -974,7 +984,7 @@ abstract class AbstractQuery
|
||||
* Load from second level cache or executes the query and put into cache.
|
||||
*
|
||||
* @param ArrayCollection|array|null $parameters
|
||||
* @param integer|null $hydrationMode
|
||||
* @param string|int|null $hydrationMode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@@ -75,6 +75,10 @@ class DefaultEntityHydrator implements EntityHydrator
|
||||
$data = $this->uow->getOriginalEntityData($entity);
|
||||
$data = array_merge($data, $metadata->getIdentifierValues($entity)); // why update has no identifier values ?
|
||||
|
||||
if ($metadata->isVersioned) {
|
||||
$data[$metadata->versionField] = $metadata->getFieldValue($entity, $metadata->versionField);
|
||||
}
|
||||
|
||||
foreach ($metadata->associationMappings as $name => $assoc) {
|
||||
if ( ! isset($data[$name])) {
|
||||
continue;
|
||||
|
||||
@@ -23,6 +23,7 @@ use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\LockMode;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Proxy\ProxyFactory;
|
||||
use Doctrine\ORM\Query\FilterCollection;
|
||||
@@ -380,6 +381,10 @@ use Throwable;
|
||||
{
|
||||
$class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
|
||||
|
||||
if ($lockMode !== null) {
|
||||
$this->checkLockRequirements($lockMode, $class);
|
||||
}
|
||||
|
||||
if ( ! is_array($id)) {
|
||||
if ($class->isIdentifierComposite) {
|
||||
throw ORMInvalidArgumentException::invalidCompositeIdentifier();
|
||||
@@ -441,10 +446,6 @@ use Throwable;
|
||||
|
||||
switch (true) {
|
||||
case LockMode::OPTIMISTIC === $lockMode:
|
||||
if ( ! $class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($class->name);
|
||||
}
|
||||
|
||||
$entity = $persister->load($sortedId);
|
||||
|
||||
$unitOfWork->lock($entity, $lockMode, $lockVersion);
|
||||
@@ -453,10 +454,6 @@ use Throwable;
|
||||
|
||||
case LockMode::PESSIMISTIC_READ === $lockMode:
|
||||
case LockMode::PESSIMISTIC_WRITE === $lockMode:
|
||||
if ( ! $this->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
|
||||
return $persister->load($sortedId, null, null, [], $lockMode);
|
||||
|
||||
default:
|
||||
@@ -915,4 +912,26 @@ use Throwable;
|
||||
{
|
||||
return null !== $this->filterCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lockMode
|
||||
* @param ClassMetadata $class
|
||||
* @throws OptimisticLockException
|
||||
* @throws TransactionRequiredException
|
||||
*/
|
||||
private function checkLockRequirements(int $lockMode, ClassMetadata $class): void
|
||||
{
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
if (!$class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($class->name);
|
||||
}
|
||||
break;
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
if (!$this->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
* @param string $entityName The name of the entity type.
|
||||
* @param mixed $identifier The entity identifier.
|
||||
*
|
||||
* @return object The (partial) entity reference.
|
||||
* @return object|null The (partial) entity reference.
|
||||
*/
|
||||
public function getPartialReference($entityName, $identifier);
|
||||
|
||||
@@ -249,7 +249,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param int $hydrationMode
|
||||
* @param string|int $hydrationMode
|
||||
*
|
||||
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator
|
||||
*/
|
||||
@@ -258,7 +258,7 @@ interface EntityManagerInterface extends ObjectManager
|
||||
/**
|
||||
* Create a new instance for the given hydration mode.
|
||||
*
|
||||
* @param int $hydrationMode
|
||||
* @param string|int $hydrationMode
|
||||
*
|
||||
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace Doctrine\ORM;
|
||||
|
||||
use Doctrine\Common\Util\Inflector;
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class AbstractIdGenerator
|
||||
* Generates an identifier for an entity.
|
||||
*
|
||||
* @param EntityManager $em
|
||||
* @param \Doctrine\ORM\Mapping\Entity $entity
|
||||
* @param object|null $entity
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function generate(EntityManager $em, $entity);
|
||||
|
||||
@@ -164,6 +164,17 @@ class CommitOrderCalculator
|
||||
case self::IN_PROGRESS:
|
||||
if (isset($adjacentVertex->dependencyList[$vertex->hash]) &&
|
||||
$adjacentVertex->dependencyList[$vertex->hash]->weight < $edge->weight) {
|
||||
|
||||
// If we have some non-visited dependencies in the in-progress dependency, we
|
||||
// need to visit them before adding the node.
|
||||
foreach ($adjacentVertex->dependencyList as $adjacentEdge) {
|
||||
$adjacentEdgeVertex = $this->nodeList[$adjacentEdge->to];
|
||||
|
||||
if ($adjacentEdgeVertex->state === self::NOT_VISITED) {
|
||||
$this->visit($adjacentEdgeVertex);
|
||||
}
|
||||
}
|
||||
|
||||
$adjacentVertex->state = self::VISITED;
|
||||
|
||||
$this->sortedNodeList[] = $adjacentVertex->value;
|
||||
|
||||
@@ -24,6 +24,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Events;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use PDO;
|
||||
use function array_map;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Base class for all hydrators. A hydrator is a class that provides some form
|
||||
@@ -296,11 +298,8 @@ abstract class AbstractHydrator
|
||||
|
||||
// If there are field name collisions in the child class, then we need
|
||||
// to only hydrate if we are looking at the correct discriminator value
|
||||
if(
|
||||
isset($cacheKeyInfo['discriminatorColumn']) &&
|
||||
isset($data[$cacheKeyInfo['discriminatorColumn']]) &&
|
||||
// Note: loose comparison required. See https://github.com/doctrine/doctrine2/pull/6304#issuecomment-323294442
|
||||
$data[$cacheKeyInfo['discriminatorColumn']] != $cacheKeyInfo['discriminatorValue']
|
||||
if (isset($cacheKeyInfo['discriminatorColumn'], $data[$cacheKeyInfo['discriminatorColumn']])
|
||||
&& ! in_array((string) $data[$cacheKeyInfo['discriminatorColumn']], $cacheKeyInfo['discriminatorValues'], true)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
@@ -401,7 +400,8 @@ abstract class AbstractHydrator
|
||||
$columnInfo,
|
||||
[
|
||||
'discriminatorColumn' => $this->_rsm->discriminatorColumns[$ownerMap],
|
||||
'discriminatorValue' => $classMetadata->discriminatorValue
|
||||
'discriminatorValue' => $classMetadata->discriminatorValue,
|
||||
'discriminatorValues' => $this->getDiscriminatorValues($classMetadata),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -454,6 +454,23 @@ abstract class AbstractHydrator
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function getDiscriminatorValues(ClassMetadata $classMetadata) : array
|
||||
{
|
||||
$values = array_map(
|
||||
function (string $subClass) : string {
|
||||
return (string) $this->getClassMetadata($subClass)->discriminatorValue;
|
||||
},
|
||||
$classMetadata->subClasses
|
||||
);
|
||||
|
||||
$values[] = (string) $classMetadata->discriminatorValue;
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve ClassMetadata associated to entity class name.
|
||||
*
|
||||
|
||||
@@ -27,7 +27,6 @@ use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use ReflectionClass;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\ClassLoader;
|
||||
use Doctrine\ORM\Cache\CacheException;
|
||||
|
||||
/**
|
||||
@@ -1025,7 +1024,11 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
public function validateAssociations()
|
||||
{
|
||||
foreach ($this->associationMappings as $mapping) {
|
||||
if ( ! ClassLoader::classExists($mapping['targetEntity']) ) {
|
||||
if (
|
||||
! class_exists($mapping['targetEntity'])
|
||||
&& ! interface_exists($mapping['targetEntity'])
|
||||
&& ! trait_exists($mapping['targetEntity'])
|
||||
) {
|
||||
throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Util\Inflector;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
namespace Doctrine\ORM\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use SimpleXMLElement;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\FileDriver;
|
||||
use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder;
|
||||
@@ -429,7 +430,10 @@ class XmlDriver extends FileDriver
|
||||
if (isset($oneToManyElement->{'order-by'})) {
|
||||
$orderBy = [];
|
||||
foreach ($oneToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
|
||||
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
|
||||
$orderBy[(string) $orderByField['name']] = isset($orderByField['direction'])
|
||||
? (string) $orderByField['direction']
|
||||
: Criteria::ASC
|
||||
;
|
||||
}
|
||||
$mapping['orderBy'] = $orderBy;
|
||||
}
|
||||
@@ -545,7 +549,9 @@ class XmlDriver extends FileDriver
|
||||
if (isset($manyToManyElement->{'order-by'})) {
|
||||
$orderBy = [];
|
||||
foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
|
||||
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
|
||||
$orderBy[(string) $orderByField['name']] = isset($orderByField['direction'])
|
||||
? (string) $orderByField['direction']
|
||||
: Criteria::ASC;
|
||||
}
|
||||
$mapping['orderBy'] = $orderBy;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) {
|
||||
$params[] = isset($sourceClass->fieldNames[$refColumnName])
|
||||
? $identifier[$sourceClass->fieldNames[$refColumnName]]
|
||||
: $identifier[$sourceClass->getFieldForColumn($columnName)];
|
||||
: $identifier[$sourceClass->getFieldForColumn($refColumnName)];
|
||||
}
|
||||
|
||||
return $params;
|
||||
|
||||
@@ -37,6 +37,8 @@ use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
use Doctrine\ORM\Utility\IdentifierFlattener;
|
||||
use Doctrine\ORM\Utility\PersisterHelper;
|
||||
use function array_merge;
|
||||
use function reset;
|
||||
|
||||
/**
|
||||
* A BasicEntityPersister maps an entity to a single table in a relational database.
|
||||
@@ -451,23 +453,21 @@ class BasicEntityPersister implements EntityPersister
|
||||
continue;
|
||||
}
|
||||
|
||||
$params[] = $identifier[$idField];
|
||||
$where[] = $this->class->associationMappings[$idField]['joinColumns'][0]['name'];
|
||||
$targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']);
|
||||
$params[] = $identifier[$idField];
|
||||
$where[] = $this->quoteStrategy->getJoinColumnName(
|
||||
$this->class->associationMappings[$idField]['joinColumns'][0],
|
||||
$this->class,
|
||||
$this->platform
|
||||
);
|
||||
|
||||
switch (true) {
|
||||
case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])):
|
||||
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
|
||||
break;
|
||||
$targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']);
|
||||
$targetType = PersisterHelper::getTypeOfField($targetMapping->identifier[0], $targetMapping, $this->em);
|
||||
|
||||
case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])):
|
||||
$types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type'];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ORMException::unrecognizedField($targetMapping->identifier[0]);
|
||||
if ($targetType === []) {
|
||||
throw ORMException::unrecognizedField($targetMapping->identifier[0]);
|
||||
}
|
||||
|
||||
$types[] = reset($targetType);
|
||||
}
|
||||
|
||||
if ($versioned) {
|
||||
|
||||
@@ -656,7 +656,7 @@ final class Query extends AbstractQuery
|
||||
* iterated over the result.
|
||||
*
|
||||
* @param ArrayCollection|array|null $parameters The query parameters.
|
||||
* @param integer $hydrationMode The hydration mode to use.
|
||||
* @param string|int $hydrationMode The hydration mode to use.
|
||||
*
|
||||
* @return \Doctrine\ORM\Internal\Hydration\IterableResult
|
||||
*/
|
||||
|
||||
@@ -41,10 +41,8 @@ class Expr
|
||||
* // (u.type = ?1) AND (u.role = ?2)
|
||||
* $expr->andX($expr->eq('u.type', ':1'), $expr->eq('u.role', ':2'));
|
||||
*
|
||||
* @param \Doctrine\ORM\Query\Expr\Comparison |
|
||||
* \Doctrine\ORM\Query\Expr\Func |
|
||||
* \Doctrine\ORM\Query\Expr\Orx
|
||||
* $x Optional clause. Defaults to null, but requires at least one defined when converting to string.
|
||||
* @param Expr\Comparison|Expr\Func|Expr\Orx|string $x Optional clause. Defaults to null, but requires at least one
|
||||
* defined when converting to string.
|
||||
*
|
||||
* @return Expr\Andx
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class Base
|
||||
protected $parts = [];
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @param mixed $args
|
||||
*/
|
||||
public function __construct($args = [])
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
namespace Doctrine\ORM\Query;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
/**
|
||||
* Scans a DQL query for tokens.
|
||||
*
|
||||
@@ -27,7 +29,7 @@ namespace Doctrine\ORM\Query;
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Lexer extends \Doctrine\Common\Lexer
|
||||
class Lexer extends AbstractLexer
|
||||
{
|
||||
// All tokens that are not valid identifiers must be < 100
|
||||
const T_NONE = 1;
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\Query\AST\Functions;
|
||||
use function strpos;
|
||||
|
||||
/**
|
||||
* An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language.
|
||||
@@ -303,21 +304,24 @@ class Parser
|
||||
$lookaheadType = $this->lexer->lookahead['type'];
|
||||
|
||||
// Short-circuit on first condition, usually types match
|
||||
if ($lookaheadType !== $token) {
|
||||
// If parameter is not identifier (1-99) must be exact match
|
||||
if ($token < Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
if ($lookaheadType === $token) {
|
||||
$this->lexer->moveNext();
|
||||
return;
|
||||
}
|
||||
|
||||
// If parameter is keyword (200+) must be exact match
|
||||
if ($token > Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
// If parameter is not identifier (1-99) must be exact match
|
||||
if ($token < Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
|
||||
// If parameter is T_IDENTIFIER, then matches T_IDENTIFIER (100) and keywords (200+)
|
||||
if ($token === Lexer::T_IDENTIFIER && $lookaheadType < Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
// If parameter is keyword (200+) must be exact match
|
||||
if ($token > Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
|
||||
// If parameter is T_IDENTIFIER, then matches T_IDENTIFIER (100) and keywords (200+)
|
||||
if ($token === Lexer::T_IDENTIFIER && $lookaheadType < Lexer::T_IDENTIFIER) {
|
||||
$this->syntaxError($this->lexer->getLiteral($token));
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
@@ -958,20 +962,20 @@ class Parser
|
||||
if ($this->lexer->isNextToken(Lexer::T_FULLY_QUALIFIED_NAME)) {
|
||||
$this->match(Lexer::T_FULLY_QUALIFIED_NAME);
|
||||
|
||||
$schemaName = $this->lexer->token['value'];
|
||||
} else if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) {
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
|
||||
$schemaName = $this->lexer->token['value'];
|
||||
} else {
|
||||
$this->match(Lexer::T_ALIASED_NAME);
|
||||
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $this->lexer->token['value']);
|
||||
|
||||
$schemaName = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
return $this->lexer->token['value'];
|
||||
}
|
||||
|
||||
return $schemaName;
|
||||
if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) {
|
||||
$this->match(Lexer::T_IDENTIFIER);
|
||||
|
||||
return $this->lexer->token['value'];
|
||||
}
|
||||
|
||||
$this->match(Lexer::T_ALIASED_NAME);
|
||||
|
||||
[$namespaceAlias, $simpleClassName] = explode(':', $this->lexer->token['value']);
|
||||
|
||||
return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1280,7 +1284,9 @@ class Parser
|
||||
$this->match(Lexer::T_AS);
|
||||
}
|
||||
|
||||
$aliasIdentificationVariable = $this->AliasIdentificationVariable();
|
||||
$aliasIdentificationVariable = $this->lexer->isNextToken(Lexer::T_IDENTIFIER)
|
||||
? $this->AliasIdentificationVariable()
|
||||
: 'alias_should_have_been_set';
|
||||
|
||||
$deleteClause->aliasIdentificationVariable = $aliasIdentificationVariable;
|
||||
$class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);
|
||||
@@ -2918,6 +2924,10 @@ class Parser
|
||||
case Lexer::T_COALESCE:
|
||||
case Lexer::T_NULLIF:
|
||||
return $this->CaseExpression();
|
||||
default:
|
||||
if ($this->isAggregateFunction($lookaheadType)) {
|
||||
return $this->AggregateExpression();
|
||||
}
|
||||
}
|
||||
|
||||
$this->syntaxError(
|
||||
|
||||
@@ -1027,7 +1027,7 @@ class QueryBuilder
|
||||
* </code>
|
||||
*
|
||||
* @param string $key The key/field to set.
|
||||
* @param string $value The value, expression, placeholder, etc.
|
||||
* @param mixed $value The value, expression, placeholder, etc.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
use Doctrine\Common\Util\Inflector;
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Util\Inflector;
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class XmlExporter extends AbstractExporter
|
||||
$xml = new SimpleXmlElement('<?xml version="1.0" encoding="utf-8"?><doctrine-mapping ' .
|
||||
'xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" ' .
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' .
|
||||
'xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" />');
|
||||
'xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd" />');
|
||||
|
||||
if ($metadata->isMappedSuperclass) {
|
||||
$root = $xml->addChild('mapped-superclass');
|
||||
|
||||
@@ -145,6 +145,7 @@ class Paginator implements \Countable, \IteratorAggregate
|
||||
$subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class);
|
||||
} else {
|
||||
$this->appendTreeWalker($subQuery, LimitSubqueryWalker::class);
|
||||
$this->unbindUnusedQueryParams($subQuery);
|
||||
}
|
||||
|
||||
$subQuery->setFirstResult($offset)->setMaxResults($length);
|
||||
@@ -256,14 +257,20 @@ class Paginator implements \Countable, \IteratorAggregate
|
||||
$countQuery->setResultSetMapping($rsm);
|
||||
} else {
|
||||
$this->appendTreeWalker($countQuery, CountWalker::class);
|
||||
$this->unbindUnusedQueryParams($countQuery);
|
||||
}
|
||||
|
||||
$countQuery->setFirstResult(null)->setMaxResults(null);
|
||||
|
||||
$parser = new Parser($countQuery);
|
||||
return $countQuery;
|
||||
}
|
||||
|
||||
private function unbindUnusedQueryParams(Query $query): void
|
||||
{
|
||||
$parser = new Parser($query);
|
||||
$parameterMappings = $parser->parse()->getParameterMappings();
|
||||
/* @var $parameters \Doctrine\Common\Collections\Collection|\Doctrine\ORM\Query\Parameter[] */
|
||||
$parameters = $countQuery->getParameters();
|
||||
$parameters = $query->getParameters();
|
||||
|
||||
foreach ($parameters as $key => $parameter) {
|
||||
$parameterName = $parameter->getName();
|
||||
@@ -273,8 +280,6 @@ class Paginator implements \Countable, \IteratorAggregate
|
||||
}
|
||||
}
|
||||
|
||||
$countQuery->setParameters($parameters);
|
||||
|
||||
return $countQuery;
|
||||
$query->setParameters($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
|
||||
*/
|
||||
class SchemaTool
|
||||
{
|
||||
private const KNOWN_COLUMN_OPTIONS = ['comment', 'unsigned', 'fixed', 'default'];
|
||||
|
||||
/**
|
||||
* @var \Doctrine\ORM\EntityManagerInterface
|
||||
*/
|
||||
@@ -467,19 +469,8 @@ class SchemaTool
|
||||
$options['columnDefinition'] = $mapping['columnDefinition'];
|
||||
}
|
||||
|
||||
if (isset($mapping['options'])) {
|
||||
$knownOptions = ['comment', 'unsigned', 'fixed', 'default'];
|
||||
|
||||
foreach ($knownOptions as $knownOption) {
|
||||
if (array_key_exists($knownOption, $mapping['options'])) {
|
||||
$options[$knownOption] = $mapping['options'][$knownOption];
|
||||
|
||||
unset($mapping['options'][$knownOption]);
|
||||
}
|
||||
}
|
||||
|
||||
$options['customSchemaOptions'] = $mapping['options'];
|
||||
}
|
||||
// the 'default' option can be overwritten here
|
||||
$options = $this->gatherColumnOptions($mapping) + $options;
|
||||
|
||||
if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == [$mapping['fieldName']]) {
|
||||
$options['autoincrement'] = true;
|
||||
@@ -690,9 +681,7 @@ class SchemaTool
|
||||
$columnOptions['notnull'] = ! $joinColumn['nullable'];
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['options'])) {
|
||||
$columnOptions['options'] = $fieldMapping['options'];
|
||||
}
|
||||
$columnOptions = $columnOptions + $this->gatherColumnOptions($fieldMapping);
|
||||
|
||||
if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) {
|
||||
$columnOptions['length'] = $fieldMapping['length'];
|
||||
@@ -745,6 +734,23 @@ class SchemaTool
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $mapping
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function gatherColumnOptions(array $mapping) : array
|
||||
{
|
||||
if (! isset($mapping['options'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$options = array_intersect_key($mapping['options'], array_flip(self::KNOWN_COLUMN_OPTIONS));
|
||||
$options['customSchemaOptions'] = array_diff_key($mapping['options'], $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the database schema for the given classes.
|
||||
*
|
||||
|
||||
@@ -181,9 +181,9 @@ class SchemaValidator
|
||||
|
||||
$identifierColumns = $targetMetadata->getIdentifierColumnNames();
|
||||
foreach ($assoc['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
|
||||
if (!in_array($inverseJoinColumn['referencedColumnName'], $identifierColumns)) {
|
||||
$ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " .
|
||||
"has to be a primary key column on the target entity class '".$targetMetadata->name."'.";
|
||||
if (! in_array($inverseJoinColumn['referencedColumnName'], $identifierColumns)) {
|
||||
$ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " .
|
||||
"has to be a primary key column on the target entity class '" .$targetMetadata->name . "'.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,11 +171,11 @@ class Setup
|
||||
|
||||
|
||||
if (extension_loaded('memcached')) {
|
||||
$memcache = new \Memcached();
|
||||
$memcache->addServer('127.0.0.1', 11211);
|
||||
$memcached = new \Memcached();
|
||||
$memcached->addServer('127.0.0.1', 11211);
|
||||
|
||||
$cache = new \Doctrine\Common\Cache\MemcachedCache();
|
||||
$cache->setMemcache($memcache);
|
||||
$cache->setMemcached($memcached);
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
@@ -940,7 +940,11 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$class->setIdentifierValues($entity, $idValue);
|
||||
}
|
||||
|
||||
$this->entityIdentifiers[$oid] = $idValue;
|
||||
// Some identifiers may be foreign keys to new entities.
|
||||
// In this case, we don't have the value yet and should treat it as if we have a post-insert generator
|
||||
if (! $this->hasMissingIdsWhichAreForeignKeys($class, $idValue)) {
|
||||
$this->entityIdentifiers[$oid] = $idValue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityStates[$oid] = self::STATE_MANAGED;
|
||||
@@ -948,6 +952,20 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$this->scheduleForInsert($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $idValue
|
||||
*/
|
||||
private function hasMissingIdsWhichAreForeignKeys(ClassMetadata $class, array $idValue) : bool
|
||||
{
|
||||
foreach ($idValue as $idField => $idFieldValue) {
|
||||
if ($idFieldValue === null && isset($class->associationMappings[$idField])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL:
|
||||
* Computes the changeset of an individual entity, independently of the
|
||||
@@ -1033,12 +1051,16 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$persister = $this->getEntityPersister($className);
|
||||
$invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postPersist);
|
||||
|
||||
$insertionsForClass = [];
|
||||
|
||||
foreach ($this->entityInsertions as $oid => $entity) {
|
||||
|
||||
if ($this->em->getClassMetadata(get_class($entity))->name !== $className) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$insertionsForClass[$oid] = $entity;
|
||||
|
||||
$persister->addInsert($entity);
|
||||
|
||||
unset($this->entityInsertions[$oid]);
|
||||
@@ -1067,6 +1089,14 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
$this->addToIdentityMap($entity);
|
||||
}
|
||||
} else {
|
||||
foreach ($insertionsForClass as $oid => $entity) {
|
||||
if (! isset($this->entityIdentifiers[$oid])) {
|
||||
//entity was not added to identity map because some identifiers are foreign keys to new entities.
|
||||
//add it now
|
||||
$this->addToEntityIdentifiersAndEntityMap($class, $oid, $entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
@@ -1074,6 +1104,30 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $entity
|
||||
*/
|
||||
private function addToEntityIdentifiersAndEntityMap(ClassMetadata $class, string $oid, $entity): void
|
||||
{
|
||||
$identifier = [];
|
||||
|
||||
foreach ($class->getIdentifierFieldNames() as $idField) {
|
||||
$value = $class->getFieldValue($entity, $idField);
|
||||
|
||||
if (isset($class->associationMappings[$idField])) {
|
||||
// NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
|
||||
$value = $this->getSingleIdentifierValue($value);
|
||||
}
|
||||
|
||||
$identifier[$idField] = $this->originalEntityData[$oid][$idField] = $value;
|
||||
}
|
||||
|
||||
$this->entityStates[$oid] = self::STATE_MANAGED;
|
||||
$this->entityIdentifiers[$oid] = $identifier;
|
||||
|
||||
$this->addToIdentityMap($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes all entity updates for entities of the specified type.
|
||||
*
|
||||
@@ -2661,7 +2715,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$class->reflFields[$field]->setValue($entity, $data[$field]);
|
||||
$this->originalEntityData[$oid][$field] = $data[$field];
|
||||
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
$associatedId = [];
|
||||
@@ -2690,7 +2744,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$class->reflFields[$field]->setValue($entity, null);
|
||||
$this->originalEntityData[$oid][$field] = null;
|
||||
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! isset($hints['fetchMode'][$class->name][$field])) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.6.0';
|
||||
const VERSION = '2.6.3';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\GH7141;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class GH7141Article
|
||||
{
|
||||
private $tags;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\GH7316;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class GH7316Article
|
||||
{
|
||||
private $tags;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tags = new ArrayCollection();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ManyToManyPersister;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="manytomanypersister_child")
|
||||
*/
|
||||
class ChildClass
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id1", type="integer")
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $id1;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"})
|
||||
* @JoinColumn(name="other_parent_id", referencedColumnName="id")
|
||||
*
|
||||
* @var OtherParentClass
|
||||
*/
|
||||
public $otherParent;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity=ParentClass::class, inversedBy="children")
|
||||
* @JoinTable(
|
||||
* name="parent_child",
|
||||
* joinColumns={
|
||||
* @JoinColumn(name="child_id1", referencedColumnName="id1"),
|
||||
* @JoinColumn(name="child_id2", referencedColumnName="other_parent_id")
|
||||
* },
|
||||
* inverseJoinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var Collection|ParentClass[]
|
||||
*/
|
||||
public $parents;
|
||||
|
||||
public function __construct(int $id1, OtherParentClass $otherParent)
|
||||
{
|
||||
$this->id1 = $id1;
|
||||
$this->otherParent = $otherParent;
|
||||
$this->parents = new ArrayCollection();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ManyToManyPersister;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="manytomanypersister_other_parent")
|
||||
*/
|
||||
class OtherParentClass
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id", type="integer")
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $id;
|
||||
|
||||
public function __construct(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\ManyToManyPersister;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\Table;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Id;
|
||||
use Doctrine\ORM\Mapping\ManyToMany;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="manytomanypersister_parent")
|
||||
*/
|
||||
class ParentClass
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id", type="integer")
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity=ChildClass::class, mappedBy="parents", orphanRemoval=true, cascade={"persist"})
|
||||
*
|
||||
* @var Collection|ChildClass[]
|
||||
*/
|
||||
public $children;
|
||||
|
||||
public function __construct(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->children = new ArrayCollection();
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,39 @@ class CommitOrderCalculatorTest extends OrmTestCase
|
||||
|
||||
$this->assertSame($correctOrder, $sorted);
|
||||
}
|
||||
|
||||
public function testCommitOrdering3()
|
||||
{
|
||||
// this test corresponds to the GH7259Test::testPersistFileBeforeVersion functional test
|
||||
$class1 = new ClassMetadata(NodeClass1::class);
|
||||
$class2 = new ClassMetadata(NodeClass2::class);
|
||||
$class3 = new ClassMetadata(NodeClass3::class);
|
||||
$class4 = new ClassMetadata(NodeClass4::class);
|
||||
|
||||
$this->_calc->addNode($class1->name, $class1);
|
||||
$this->_calc->addNode($class2->name, $class2);
|
||||
$this->_calc->addNode($class3->name, $class3);
|
||||
$this->_calc->addNode($class4->name, $class4);
|
||||
|
||||
$this->_calc->addDependency($class4->name, $class1->name, 1);
|
||||
$this->_calc->addDependency($class1->name, $class2->name, 1);
|
||||
$this->_calc->addDependency($class4->name, $class3->name, 1);
|
||||
$this->_calc->addDependency($class1->name, $class4->name, 0);
|
||||
|
||||
$sorted = $this->_calc->sort();
|
||||
|
||||
// There is only multiple valid ordering for this constellation, but
|
||||
// the class4, class1, class2 ordering is important to break the cycle
|
||||
// on the nullable link.
|
||||
$correctOrders = [
|
||||
[$class4, $class1, $class2, $class3],
|
||||
[$class4, $class1, $class3, $class2],
|
||||
[$class4, $class3, $class1, $class2],
|
||||
];
|
||||
|
||||
// We want to perform a strict comparison of the array
|
||||
$this->assertContains($sorted, $correctOrders, '', false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
class NodeClass1 {}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\Tests\Models\Company\CompanyManager;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Functional Query tests.
|
||||
@@ -292,7 +293,7 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
|
||||
*
|
||||
* @dataProvider dateAddSubProvider
|
||||
*/
|
||||
public function testDateAdd(string $unit, int $amount, int $expectedValue, int $delta = 0) : void
|
||||
public function testDateAdd(string $unit, int $amount, int $delta = 0) : void
|
||||
{
|
||||
$query = sprintf(
|
||||
'SELECT CURRENT_TIMESTAMP() as now, DATE_ADD(CURRENT_TIMESTAMP(), %d, \'%s\') AS add FROM %s m',
|
||||
@@ -308,9 +309,12 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
|
||||
self::assertArrayHasKey('now', $result);
|
||||
self::assertArrayHasKey('add', $result);
|
||||
|
||||
$diff = strtotime($result['add']) - strtotime($result['now']);
|
||||
|
||||
self::assertEquals($expectedValue, $diff, '', $delta);
|
||||
self::assertEquals(
|
||||
(new \DateTimeImmutable($result['now']))->modify(sprintf('+%d %s', $amount, $unit)),
|
||||
new \DateTimeImmutable($result['add']),
|
||||
'',
|
||||
$delta
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,7 +323,7 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
|
||||
*
|
||||
* @dataProvider dateAddSubProvider
|
||||
*/
|
||||
public function testDateSub(string $unit, int $amount, int $expectedValue, int $delta = 0) : void
|
||||
public function testDateSub(string $unit, int $amount, int $delta = 0) : void
|
||||
{
|
||||
$query = sprintf(
|
||||
'SELECT CURRENT_TIMESTAMP() as now, DATE_SUB(CURRENT_TIMESTAMP(), %d, \'%s\') AS sub FROM %s m',
|
||||
@@ -335,9 +339,12 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
|
||||
self::assertArrayHasKey('now', $result);
|
||||
self::assertArrayHasKey('sub', $result);
|
||||
|
||||
$diff = strtotime($result['now']) - strtotime($result['sub']);
|
||||
|
||||
self::assertEquals($expectedValue, $diff, '', $delta);
|
||||
self::assertEquals(
|
||||
(new \DateTimeImmutable($result['now']))->modify(sprintf('-%d %s', $amount, $unit)),
|
||||
new \DateTimeImmutable($result['sub']),
|
||||
'',
|
||||
$delta
|
||||
);
|
||||
}
|
||||
|
||||
public function dateAddSubProvider() : array
|
||||
@@ -345,9 +352,10 @@ class QueryDqlFunctionTest extends OrmFunctionalTestCase
|
||||
$secondsInDay = 86400;
|
||||
|
||||
return [
|
||||
'year' => ['year', 1, 365 * $secondsInDay, 3 * $secondsInDay],
|
||||
'month' => ['month', 1, 30 * $secondsInDay, 2 * $secondsInDay],
|
||||
'week' => ['week', 1, 7 * $secondsInDay, $secondsInDay],
|
||||
'year' => ['year', 1, $secondsInDay],
|
||||
'month' => ['month', 1, $secondsInDay],
|
||||
'week' => ['week', 1, $secondsInDay],
|
||||
'day' => ['day', 2, $secondsInDay],
|
||||
'hour' => ['hour', 1, 3600],
|
||||
'minute' => ['minute', 1, 60],
|
||||
'second' => ['second', 10, 10],
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
final class GH6531Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setup();
|
||||
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
GH6531User::class,
|
||||
GH6531Address::class,
|
||||
GH6531Article::class,
|
||||
GH6531ArticleAttribute::class,
|
||||
GH6531Order::class,
|
||||
GH6531OrderItem::class,
|
||||
GH6531Product::class,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6531
|
||||
*/
|
||||
public function testSimpleDerivedIdentity() : void
|
||||
{
|
||||
$user = new GH6531User();
|
||||
$address = new GH6531Address();
|
||||
$address->user = $user;
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->persist($address);
|
||||
$this->_em->flush();
|
||||
|
||||
self::assertSame($user, $this->_em->find(GH6531User::class, $user->id));
|
||||
self::assertSame($address, $this->_em->find(GH6531Address::class, $user));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6531
|
||||
*/
|
||||
public function testDynamicAttributes() : void
|
||||
{
|
||||
$article = new GH6531Article();
|
||||
$article->addAttribute('name', 'value');
|
||||
|
||||
$this->_em->persist($article);
|
||||
$this->_em->flush();
|
||||
|
||||
self::assertSame(
|
||||
$article->attributes['name'],
|
||||
$this->_em->find(GH6531ArticleAttribute::class, ['article' => $article, 'attribute' => 'name'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6531
|
||||
*/
|
||||
public function testJoinTableWithMetadata() : void
|
||||
{
|
||||
$product = new GH6531Product();
|
||||
$this->_em->persist($product);
|
||||
$this->_em->flush();
|
||||
|
||||
$order = new GH6531Order();
|
||||
$order->addItem($product, 2);
|
||||
|
||||
$this->_em->persist($order);
|
||||
$this->_em->flush();
|
||||
|
||||
self::assertSame(
|
||||
$order->items->first(),
|
||||
$this->_em->find(GH6531OrderItem::class, ['product' => $product, 'order' => $order])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531User
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531Address
|
||||
{
|
||||
/** @Id @OneToOne(targetEntity=GH6531User::class) */
|
||||
public $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531Article
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
|
||||
/** @OneToMany(targetEntity=GH6531ArticleAttribute::class, mappedBy="article", cascade={"ALL"}, indexBy="attribute") */
|
||||
public $attributes;
|
||||
|
||||
public function addAttribute(string $name, string $value)
|
||||
{
|
||||
$this->attributes[$name] = new GH6531ArticleAttribute($name, $value, $this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531ArticleAttribute
|
||||
{
|
||||
/** @Id @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") */
|
||||
public $article;
|
||||
|
||||
/** @Id @Column(type="string") */
|
||||
public $attribute;
|
||||
|
||||
/** @Column(type="string") */
|
||||
public $value;
|
||||
|
||||
public function __construct(string $name, string $value, GH6531Article $article)
|
||||
{
|
||||
$this->attribute = $name;
|
||||
$this->value = $value;
|
||||
$this->article = $article;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531Order
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
|
||||
/** @OneToMany(targetEntity=GH6531OrderItem::class, mappedBy="order", cascade={"ALL"}) */
|
||||
public $items;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->items = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function addItem(GH6531Product $product, int $amount) : void
|
||||
{
|
||||
$this->items->add(new GH6531OrderItem($this, $product, $amount));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531Product
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6531OrderItem
|
||||
{
|
||||
/** @Id @ManyToOne(targetEntity=GH6531Order::class) */
|
||||
public $order;
|
||||
|
||||
/** @Id @ManyToOne(targetEntity=GH6531Product::class) */
|
||||
public $product;
|
||||
|
||||
/** @Column(type="integer") */
|
||||
public $amount = 1;
|
||||
|
||||
public function __construct(GH6531Order $order, GH6531Product $product, int $amount = 1)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->product = $product;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* @group 6937
|
||||
*/
|
||||
final class GH6937Test extends OrmFunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema([GH6937Person::class, GH6937Employee::class, GH6937Manager::class]);
|
||||
}
|
||||
|
||||
public function testPhoneNumberIsPopulatedWithFind() : void
|
||||
{
|
||||
$manager = new GH6937Manager();
|
||||
$manager->name = 'Kevin';
|
||||
$manager->phoneNumber = '555-5555';
|
||||
$manager->department = 'Accounting';
|
||||
|
||||
$this->_em->persist($manager);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$persistedManager = $this->_em->find(GH6937Person::class, $manager->id);
|
||||
|
||||
self::assertSame('Kevin', $persistedManager->name);
|
||||
self::assertSame('555-5555', $persistedManager->phoneNumber);
|
||||
self::assertSame('Accounting', $persistedManager->department);
|
||||
}
|
||||
|
||||
public function testPhoneNumberIsPopulatedWithQueryBuilderUsingSimpleObjectHydrator() : void
|
||||
{
|
||||
$manager = new GH6937Manager();
|
||||
$manager->name = 'Kevin';
|
||||
$manager->phoneNumber = '555-5555';
|
||||
$manager->department = 'Accounting';
|
||||
|
||||
$this->_em->persist($manager);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$persistedManager = $this->_em->getRepository(GH6937Person::class)
|
||||
->createQueryBuilder('e')
|
||||
->where('e.id = :id')
|
||||
->setParameter('id', $manager->id)
|
||||
->getQuery()
|
||||
->getOneOrNullResult(AbstractQuery::HYDRATE_SIMPLEOBJECT);
|
||||
|
||||
self::assertSame('Kevin', $persistedManager->name);
|
||||
self::assertSame('555-5555', $persistedManager->phoneNumber);
|
||||
self::assertSame('Accounting', $persistedManager->department);
|
||||
}
|
||||
|
||||
public function testPhoneNumberIsPopulatedWithQueryBuilder() : void
|
||||
{
|
||||
$manager = new GH6937Manager();
|
||||
$manager->name = 'Kevin';
|
||||
$manager->phoneNumber = '555-5555';
|
||||
$manager->department = 'Accounting';
|
||||
|
||||
$this->_em->persist($manager);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$persistedManager = $this->_em->getRepository(GH6937Person::class)
|
||||
->createQueryBuilder('e')
|
||||
->where('e.id = :id')
|
||||
->setParameter('id', $manager->id)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
|
||||
self::assertSame('Kevin', $persistedManager->name);
|
||||
self::assertSame('555-5555', $persistedManager->phoneNumber);
|
||||
self::assertSame('Accounting', $persistedManager->department);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("JOINED")
|
||||
* @DiscriminatorColumn(name="discr", type="string")
|
||||
* @DiscriminatorMap({"employee"=GH6937Employee::class, "manager"=GH6937Manager::class})
|
||||
*/
|
||||
abstract class GH6937Person
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
|
||||
/** @Column(type="string") */
|
||||
public $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
abstract class GH6937Employee extends GH6937Person
|
||||
{
|
||||
/** @Column(type="string") */
|
||||
public $phoneNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH6937Manager extends GH6937Employee
|
||||
{
|
||||
/** @Column(type="string") */
|
||||
public $department;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\Models\Quote\User as QuotedUser;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
final class GH7012Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->useModelSet('quote');
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema([GH7012UserData::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 7012
|
||||
*/
|
||||
public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn() : void
|
||||
{
|
||||
$user = new QuotedUser();
|
||||
$user->name = 'John Doe';
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->flush();
|
||||
|
||||
$userData = new GH7012UserData($user, '123456789');
|
||||
|
||||
$this->_em->persist($userData);
|
||||
$this->_em->flush();
|
||||
|
||||
$userData->name = '4321';
|
||||
$this->_em->flush();
|
||||
|
||||
$platform = $this->_em->getConnection()->getDatabasePlatform();
|
||||
$quotedTableName = $platform->quoteIdentifier('quote-user-data');
|
||||
$quotedColumn = $platform->quoteIdentifier('name');
|
||||
$quotedIdentifier = $platform->quoteIdentifier('user-id');
|
||||
|
||||
self::assertNotEquals('quote-user-data', $quotedTableName);
|
||||
self::assertNotEquals('name', $quotedColumn);
|
||||
self::assertNotEquals('user-id', $quotedIdentifier);
|
||||
|
||||
$queries = $this->_sqlLoggerStack->queries;
|
||||
|
||||
$this->assertSQLEquals(
|
||||
sprintf('UPDATE %s SET %s = ? WHERE %s = ?', $quotedTableName, $quotedColumn, $quotedIdentifier),
|
||||
$queries[$this->_sqlLoggerStack->currentQuery - 1]['sql']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="`quote-user-data`")
|
||||
*/
|
||||
class GH7012UserData
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @OneToOne(targetEntity=Doctrine\Tests\Models\Quote\User::class)
|
||||
* @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @Column(type="string", name="`name`")
|
||||
*/
|
||||
public $name;
|
||||
|
||||
public function __construct(QuotedUser $user, string $name)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
class GH7062Test extends OrmFunctionalTestCase
|
||||
{
|
||||
private const SEASON_ID = 'season_18';
|
||||
private const TEAM_ID = 'team_A';
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
GH7062Team::class,
|
||||
GH7062Season::class,
|
||||
GH7062Ranking::class,
|
||||
GH7062RankingPosition::class
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 7062
|
||||
*/
|
||||
public function testEntityWithAssociationKeyIdentityCanBeUpdated() : void
|
||||
{
|
||||
$this->createInitialRankingWithRelatedEntities();
|
||||
$this->modifyRanking();
|
||||
$this->verifyRanking();
|
||||
}
|
||||
|
||||
private function createInitialRankingWithRelatedEntities() : void
|
||||
{
|
||||
$team = new GH7062Team(self::TEAM_ID);
|
||||
$season = new GH7062Season(self::SEASON_ID);
|
||||
|
||||
$season->ranking = new GH7062Ranking($season, [$team]);
|
||||
|
||||
$this->_em->persist($team);
|
||||
$this->_em->persist($season);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
foreach ($season->ranking->positions as $position) {
|
||||
self::assertSame(0, $position->points);
|
||||
}
|
||||
}
|
||||
|
||||
private function modifyRanking() : void
|
||||
{
|
||||
/** @var GH7062Ranking $ranking */
|
||||
$ranking = $this->_em->find(GH7062Ranking::class, self::SEASON_ID);
|
||||
|
||||
foreach ($ranking->positions as $position) {
|
||||
$position->points += 3;
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
private function verifyRanking() : void
|
||||
{
|
||||
/** @var GH7062Season $season */
|
||||
$season = $this->_em->find(GH7062Season::class, self::SEASON_ID);
|
||||
self::assertInstanceOf(GH7062Season::class, $season);
|
||||
|
||||
$ranking = $season->ranking;
|
||||
self::assertInstanceOf(GH7062Ranking::class, $ranking);
|
||||
|
||||
foreach ($ranking->positions as $position) {
|
||||
self::assertSame(3, $position->points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Entity whose identity is defined through another Entity (Season)
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="soccer_rankings")
|
||||
*/
|
||||
class GH7062Ranking
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking")
|
||||
* @JoinColumn(name="season", referencedColumnName="id")
|
||||
*
|
||||
* @var GH7062Season
|
||||
*/
|
||||
public $season;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity=GH7062RankingPosition::class, mappedBy="ranking", cascade={"all"})
|
||||
*
|
||||
* @var Collection|GH7062RankingPosition[]
|
||||
*/
|
||||
public $positions;
|
||||
|
||||
/**
|
||||
* @param GH7062Team[] $teams
|
||||
*/
|
||||
public function __construct(GH7062Season $season, array $teams)
|
||||
{
|
||||
$this->season = $season;
|
||||
$this->positions = new ArrayCollection();
|
||||
|
||||
foreach ($teams as $team) {
|
||||
$this->positions[] = new GH7062RankingPosition($this, $team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity which serves as a identity provider for other entities
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="soccer_seasons")
|
||||
*/
|
||||
class GH7062Season
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="string")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity=GH7062Ranking::class, mappedBy="season", cascade={"all"})
|
||||
*
|
||||
* @var GH7062Ranking|null
|
||||
*/
|
||||
public $ranking;
|
||||
|
||||
public function __construct(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity which serves as a identity provider for other entities
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="soccer_teams")
|
||||
*/
|
||||
class GH7062Team
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="string")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
public function __construct(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity whose identity is defined through two other entities
|
||||
*
|
||||
* @Entity
|
||||
* @Table(name="soccer_ranking_positions")
|
||||
*/
|
||||
class GH7062RankingPosition
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @ManyToOne(targetEntity=GH7062Ranking::class, inversedBy="positions")
|
||||
* @JoinColumn(name="season", referencedColumnName="season")
|
||||
*
|
||||
* @var GH7062Ranking
|
||||
*/
|
||||
public $ranking;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @ManyToOne(targetEntity=GH7062Team::class)
|
||||
* @JoinColumn(name="team_id", referencedColumnName="id")
|
||||
*
|
||||
* @var GH7062Team
|
||||
*/
|
||||
public $team;
|
||||
|
||||
/**
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $points;
|
||||
|
||||
public function __construct(GH7062Ranking $ranking, GH7062Team $team)
|
||||
{
|
||||
$this->ranking = $ranking;
|
||||
$this->team = $team;
|
||||
$this->points = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
final class GH7067Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->enableSecondLevelCache();
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema([GH7067Entity::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 7067
|
||||
*/
|
||||
public function testSLCWithVersion() : void
|
||||
{
|
||||
$entity = new GH7067Entity();
|
||||
$entity->lastUpdate = new \DateTime();
|
||||
|
||||
$this->_em->persist($entity);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
/** @var GH7067Entity $notCached */
|
||||
$notCached = $this->_em->find(GH7067Entity::class, $entity->id);
|
||||
|
||||
self::assertNotNull($notCached->version, 'Version already cached by persister above, it must be not null');
|
||||
|
||||
$notCached->lastUpdate = new \DateTime('+1 seconds');
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
* @Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
class GH7067Entity
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(type="datetime")
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
public $lastUpdate;
|
||||
|
||||
/**
|
||||
* @Column(type="datetime")
|
||||
* @Version
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
public $version;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\DBAL\LockMode;
|
||||
use Doctrine\ORM\TransactionRequiredException;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
final class GH7068Test extends OrmFunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
SomeEntity::class,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testLockModeIsRespected()
|
||||
{
|
||||
$entity = new SomeEntity();
|
||||
$this->_em->persist($entity);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$this->_em->find(SomeEntity::class, 1);
|
||||
|
||||
$this->expectException(TransactionRequiredException::class);
|
||||
$this->_em->find(SomeEntity::class, 1, LockMode::PESSIMISTIC_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @Entity */
|
||||
final class SomeEntity {
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
final class GH7259Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema([GH7259Space::class, GH7259File::class, GH7259FileVersion::class, GH7259Feed::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 7259
|
||||
*/
|
||||
public function testPersistFileBeforeVersion() : void
|
||||
{
|
||||
$space = new GH7259Space();
|
||||
|
||||
$this->_em->persist($space);
|
||||
$this->_em->flush();
|
||||
|
||||
$feed = new GH7259Feed();
|
||||
$feed->space = $space;
|
||||
|
||||
$file = new GH7259File();
|
||||
$file->space = $space;
|
||||
$fileVersion = new GH7259FileVersion();
|
||||
$fileVersion->file = $file;
|
||||
|
||||
$this->_em->persist($file);
|
||||
$this->_em->persist($fileVersion);
|
||||
$this->_em->persist($feed);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
self::assertNotNull($fileVersion->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 7259
|
||||
*/
|
||||
public function testPersistFileAfterVersion() : void
|
||||
{
|
||||
$space = new GH7259Space();
|
||||
|
||||
$this->_em->persist($space);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$space = $this->_em->find(GH7259Space::class, $space->id);
|
||||
|
||||
$feed = new GH7259Feed();
|
||||
$feed->space = $space;
|
||||
|
||||
$file = new GH7259File();
|
||||
$file->space = $space;
|
||||
$fileVersion = new GH7259FileVersion();
|
||||
$fileVersion->file = $file;
|
||||
|
||||
$this->_em->persist($fileVersion);
|
||||
$this->_em->persist($file);
|
||||
$this->_em->persist($feed);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
self::assertNotNull($fileVersion->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
*/
|
||||
class GH7259File
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity=GH7259Space::class)
|
||||
* @JoinColumn(nullable=false)
|
||||
*
|
||||
* @var GH7259Space|null
|
||||
*/
|
||||
public $space;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
*/
|
||||
class GH7259FileVersion
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity=GH7259File::class)
|
||||
* @JoinColumn(nullable=false)
|
||||
*
|
||||
* @var GH7259File|null
|
||||
*/
|
||||
public $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
*/
|
||||
class GH7259Space
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity=GH7259File::class)
|
||||
* @JoinColumn(nullable=true)
|
||||
*
|
||||
* @var GH7259File|null
|
||||
*/
|
||||
public $ruleFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity()
|
||||
*/
|
||||
class GH7259Feed
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity=GH7259Space::class)
|
||||
* @JoinColumn(nullable=false)
|
||||
*
|
||||
* @var GH7259Space|null
|
||||
*/
|
||||
public $space;
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\AST\Node;
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
final class GH7286Test extends OrmFunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
GH7286Entity::class,
|
||||
]
|
||||
);
|
||||
|
||||
$this->_em->persist(new GH7286Entity('foo', 1));
|
||||
$this->_em->persist(new GH7286Entity('foo', 2));
|
||||
$this->_em->persist(new GH7286Entity('bar', 3));
|
||||
$this->_em->persist(new GH7286Entity(null, 4));
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public function testAggregateExpressionInFunction() : void
|
||||
{
|
||||
$query = $this->_em->createQuery(
|
||||
'SELECT CONCAT(e.type, MIN(e.version)) pair'
|
||||
. ' FROM ' . GH7286Entity::class . ' e'
|
||||
. ' WHERE e.type IS NOT NULL'
|
||||
. ' GROUP BY e.type'
|
||||
. ' ORDER BY e.type'
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
[
|
||||
['pair' => 'bar3'],
|
||||
['pair' => 'foo1'],
|
||||
],
|
||||
$query->getArrayResult()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1091
|
||||
*/
|
||||
public function testAggregateFunctionInCustomFunction() : void
|
||||
{
|
||||
$this->_em->getConfiguration()->addCustomStringFunction('CC', GH7286CustomConcat::class);
|
||||
|
||||
$query = $this->_em->createQuery(
|
||||
'SELECT CC(e.type, MIN(e.version)) pair'
|
||||
. ' FROM ' . GH7286Entity::class . ' e'
|
||||
. ' WHERE e.type IS NOT NULL AND e.type != :type'
|
||||
. ' GROUP BY e.type'
|
||||
);
|
||||
$query->setParameter('type', 'bar');
|
||||
|
||||
self::assertSame(
|
||||
['pair' => 'foo1'],
|
||||
$query->getSingleResult()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH7286Entity
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(nullable=true)
|
||||
* @var string|null
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @Column(type="integer")
|
||||
* @var int
|
||||
*/
|
||||
public $version;
|
||||
|
||||
public function __construct(?string $type, int $version)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->version = $version;
|
||||
}
|
||||
}
|
||||
|
||||
class GH7286CustomConcat extends FunctionNode
|
||||
{
|
||||
/** @var Node */
|
||||
private $first;
|
||||
|
||||
/** @var Node */
|
||||
private $second;
|
||||
|
||||
public function parse(Parser $parser) : void
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
$this->first = $parser->StringPrimary();
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
$this->second = $parser->StringPrimary();
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
|
||||
public function getSql(SqlWalker $walker) : string
|
||||
{
|
||||
return $walker->getConnection()->getDatabasePlatform()->getConcatExpression(
|
||||
$this->first->dispatch($walker),
|
||||
$this->second->dispatch($walker)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\DBAL\LockMode;
|
||||
use Doctrine\ORM\TransactionRequiredException;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
final class GH7366Test extends OrmFunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
GH7366Entity::class,
|
||||
]
|
||||
);
|
||||
|
||||
$this->_em->persist(new GH7366Entity('baz'));
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public function testOptimisticLockNoExceptionOnFind() : void
|
||||
{
|
||||
try {
|
||||
$entity = $this->_em->find(GH7366Entity::class, 1, LockMode::OPTIMISTIC);
|
||||
} catch (TransactionRequiredException $e) {
|
||||
self::fail('EntityManager::find() threw TransactionRequiredException with LockMode::OPTIMISTIC');
|
||||
}
|
||||
self::assertEquals('baz', $entity->getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class GH7366Entity
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(type="integer")
|
||||
* @Version
|
||||
*/
|
||||
protected $lockVersion = 1;
|
||||
|
||||
/**
|
||||
* @Column(length=32)
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Doctrine\Tests\Models\OrnementalOrphanRemoval\Person" table="ornemental_orphan_removal_person">
|
||||
<id name="id" column="id">
|
||||
<generator strategy="NONE" />
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber" table="ornemental_orphan_removal_phone_number">
|
||||
<id name="id" column="id">
|
||||
<generator strategy="NONE" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Doctrine\Tests\ORM\Mapping;
|
||||
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
||||
@@ -11,6 +12,8 @@ use Doctrine\Tests\Models\DDC3293\DDC3293User;
|
||||
use Doctrine\Tests\Models\DDC3293\DDC3293UserPrefixed;
|
||||
use Doctrine\Tests\Models\DDC889\DDC889Class;
|
||||
use Doctrine\Tests\Models\Generic\SerializationModel;
|
||||
use Doctrine\Tests\Models\GH7141\GH7141Article;
|
||||
use Doctrine\Tests\Models\GH7316\GH7316Article;
|
||||
use Doctrine\Tests\Models\ValueObjects\Name;
|
||||
use Doctrine\Tests\Models\ValueObjects\Person;
|
||||
|
||||
@@ -150,8 +153,8 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
*/
|
||||
public function testValidateXmlSchema($xmlMappingFile)
|
||||
{
|
||||
$xsdSchemaFile = __DIR__ . '/../../../../../doctrine-mapping.xsd';
|
||||
$dom = new \DOMDocument('UTF-8');
|
||||
$xsdSchemaFile = __DIR__ . '/../../../../../doctrine-mapping.xsd';
|
||||
$dom = new \DOMDocument();
|
||||
|
||||
$dom->load($xmlMappingFile);
|
||||
|
||||
@@ -174,6 +177,38 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
}, $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group GH-7141
|
||||
*/
|
||||
public function testOneToManyDefaultOrderByAsc()
|
||||
{
|
||||
$driver = $this->_loadDriver();
|
||||
$class = new ClassMetadata(GH7141Article::class);
|
||||
|
||||
$class->initializeReflection(new RuntimeReflectionService());
|
||||
$driver->loadMetadataForClass(GH7141Article::class, $class);
|
||||
|
||||
|
||||
$this->assertEquals(
|
||||
Criteria::ASC,
|
||||
$class->getMetadataValue('associationMappings')['tags']['orderBy']['position']
|
||||
);
|
||||
}
|
||||
|
||||
public function testManyToManyDefaultOrderByAsc() : void
|
||||
{
|
||||
$class = new ClassMetadata(GH7316Article::class);
|
||||
$class->initializeReflection(new RuntimeReflectionService());
|
||||
|
||||
$driver = $this->_loadDriver();
|
||||
$driver->loadMetadataForClass(GH7316Article::class, $class);
|
||||
|
||||
self::assertEquals(
|
||||
Criteria::ASC,
|
||||
$class->getMetadataValue('associationMappings')['tags']['orderBy']['position']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-889
|
||||
* @expectedException \Doctrine\Common\Persistence\Mapping\MappingException
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="CatNoId">
|
||||
<field name="can_has_cheezburgers" type="boolean" />
|
||||
</entity>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="SocialLibrary\ReadBundle\Entity\Book">
|
||||
<id name="id" type="integer">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="SocialLibrary\ReadBundle\Entity\Novel" table="novel__novel" repository-class="SocialLibrary\ReadBundle\Repository\NovelRepository">
|
||||
<association-overrides>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\CMS\CmsAddress" table="cms_users">
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\CMS\CmsUser" table="cms_users">
|
||||
|
||||
<named-queries>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Doctrine\Tests\Models\Cache\City" table="cache_city">
|
||||
<cache usage="READ_ONLY" />
|
||||
<id name="id" type="integer" column="id">
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\Company\CompanyContract" table="company_contracts" inheritance-type="SINGLE_TABLE">
|
||||
|
||||
<discriminator-map>
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\Company\CompanyFixContract">
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\Company\CompanyFlexContract">
|
||||
|
||||
<field name="hoursWorked" column="hoursWorked" type="integer"/>
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\Company\CompanyFlexUltraContract">
|
||||
|
||||
<entity-listeners>
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\Company\CompanyPerson" table="company_persons" inheritance-type="JOINED">
|
||||
|
||||
<discriminator-map >
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC117\DDC117Translation">
|
||||
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType">
|
||||
<id name="id">
|
||||
<generator strategy="NONE"/>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd"
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
|
||||
>
|
||||
<entity name="Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable" table="explicit_table" schema="explicit_schema">
|
||||
<id name="id" column="id">
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd"
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
|
||||
>
|
||||
<entity name="Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName" table="implicit_schema.implicit_table">
|
||||
<id name="id" column="id">
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<embeddable name="Doctrine\Tests\Models\DDC3293\DDC3293Address">
|
||||
<field name="street" type="string" />
|
||||
<field name="city" type="string" />
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Doctrine\Tests\Models\DDC3293\DDC3293User" table="user">
|
||||
<id name="id" column="id">
|
||||
<generator strategy="UUID" />
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<entity name="Doctrine\Tests\Models\DDC3293\DDC3293UserPrefixed" table="user">
|
||||
<id name="id" column="id">
|
||||
<generator strategy="UUID" />
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC3579\DDC3579Admin">
|
||||
<association-overrides>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Doctrine\Tests\Models\DDC3579\DDC3579User">
|
||||
<id name="id" type="integer" column="user_id" length="150">
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC5934\DDC5934BaseContract">
|
||||
<id name="id" type="integer">
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC5934\DDC5934Contract">
|
||||
<association-overrides>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC869\DDC869ChequePayment">
|
||||
<field name="serialNumber" column="serialNumber" type="string"/>
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment">
|
||||
<field name="creditCardNumber" column="creditCardNumber" type="string"/>
|
||||
</entity>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Doctrine\Tests\Models\DDC869\DDC869Payment" repository-class="Doctrine\Tests\Models\DDC869\DDC869PaymentRepository">
|
||||
<id name="id" type="integer" column="id">
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<class name="Doctrine\Tests\Models\DDC889\DDC889Class">
|
||||
<id name="id" type="integer" column="id">
|
||||
<generator strategy="AUTO"/>
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC889\DDC889Entity">
|
||||
</entity>
|
||||
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Doctrine\Tests\Models\DDC889\DDC889SuperClass">
|
||||
<field name="name" column="name" type="string"/>
|
||||
</mapped-superclass>
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC964\DDC964Admin">
|
||||
<association-overrides>
|
||||
<association-override name="groups">
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\DDC964\DDC964Guest">
|
||||
<attribute-overrides>
|
||||
<attribute-override name="id">
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Doctrine\Tests\Models\DDC964\DDC964User">
|
||||
<id name="id" type="integer" column="user_id" length="150">
|
||||
<generator strategy="AUTO"/>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\GH7141\GH7141Article">
|
||||
<one-to-many field="tags" target-entity="NoTargetEntity" mapped-by="noMappedByField">
|
||||
<order-by>
|
||||
<order-by-field name="position"/>
|
||||
</order-by>
|
||||
</one-to-many>
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="Doctrine\Tests\Models\GH7316\GH7316Article">
|
||||
<many-to-many field="tags" target-entity="NoTargetEntity" mapped-by="noMappedByField">
|
||||
<order-by>
|
||||
<order-by-field name="position"/>
|
||||
</order-by>
|
||||
</many-to-many>
|
||||
</entity>
|
||||
</doctrine-mapping>
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<entity name="\stdClass">
|
||||
<id name="id" type="integer" column="id">
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
<embeddable name="Doctrine\Tests\Models\ValueObjects\Name">
|
||||
<field name="firstName"/>
|
||||
<field name="lastName"/>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user