Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Merge 3.3.x up into 4.0.x #11634

Merged
merged 72 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a3e3a3b
Merge pull request #11360 from doctrine/2.19.x-merge-up-into-2.20.x_a…
greg0ire Mar 16, 2024
d5fdd67
Reintroduce PARTIAL, but only for non-object hydration.
beberlei Mar 16, 2024
eb8510f
Add tests for adjusted functionality.
beberlei Mar 16, 2024
758f0d7
Remove Query::HINT_FORCE_PARTIAL_LOAD constant, not needed to be rein…
beberlei Mar 16, 2024
90962f0
Use id dynamically in array hydration test.
beberlei Mar 16, 2024
80278c5
Update docs/en/reference/partial-hydration.rst
beberlei Mar 16, 2024
bcdc5bd
Merge pull request #11378 from doctrine/2.19.x-merge-up-into-2.20.x_e…
greg0ire Mar 18, 2024
716da7e
Merge branch '2.19.x' into 2.20.x
derrabus Mar 21, 2024
083f642
Merge branch '2.19.x' into 2.20.x
derrabus Mar 21, 2024
be307ed
Merge release 2.19.3 into 2.20.x (#11398)
derrabus Mar 22, 2024
b725908
Merge branch '2.19.x' into 2.20.x
derrabus Apr 15, 2024
8b6a58f
Merge pull request #11432 from doctrine/2.19.x-merge-up-into-2.20.x_I…
greg0ire Apr 30, 2024
eb49f66
Merge branch '2.19.x' into 2.20.x
derrabus May 21, 2024
bf3e082
Merge branch '2.19.x' into 2.20.x
derrabus May 21, 2024
6874448
Undeprecate PARTIAL for array hydration. (#11366)
beberlei Jun 18, 2024
066ec1a
Fix upgrade guide for 2.20 (#11504)
derrabus Jun 18, 2024
83851a9
Merge branch '2.19.x' into 2.20.x
derrabus Jun 18, 2024
96d13ac
Fetching entities with Composite Key Relations and null values
michalbundyra Jun 3, 2024
d0e9177
Merge pull request #11514 from doctrine/2.19.x
greg0ire Jun 20, 2024
40f299f
Merge pull request #11506 from michalbundyra/composite-key-relations-3
greg0ire Jun 21, 2024
ce7d93f
Merge remote-tracking branch 'origin/2.19.x' into 3.2.x
greg0ire Jun 26, 2024
e3d7c60
Use modern array syntax in the doc
GromNaN Jun 26, 2024
c1bb2cc
Merge pull request #11526 from GromNaN/patch-1
greg0ire Jun 26, 2024
722cea6
Merge pull request #11525 from greg0ire/3.2.x
greg0ire Jun 26, 2024
7d01f19
Merge pull request #11531 from doctrine/2.19.x-merge-up-into-2.20.x_Q…
greg0ire Jun 27, 2024
efe62e3
Merge pull request #11532 from doctrine/3.2.x-merge-up-into-3.3.x_ws8…
greg0ire Jun 27, 2024
19129e9
working-with-objects.rst: added missing white space
k00ni Jun 28, 2024
c37b115
Merge pull request #11534 from k00ni/patch-1
greg0ire Jun 28, 2024
1fe1a6a
Fix incorrect exception message for ManyToOne attribute in embeddable…
Xesau Jul 1, 2024
9bd51aa
Fix the support for custom parameter types in native queries
stof Jul 3, 2024
51ad860
Merge pull request #11543 from stof/fix_native_query_parameter_type
greg0ire Jul 4, 2024
0983d3a
Add `createNamedParameter` to `QueryBuilder`
norkunas Jun 27, 2024
ef64cf7
Merge remote-tracking branch 'origin/2.20.x' into 3.3.x
greg0ire Jul 10, 2024
4c2f104
Merge pull request #11547 from greg0ire/3.3.x
greg0ire Jul 10, 2024
1281707
Merge pull request #11528 from norkunas/namedparams
greg0ire Jul 11, 2024
57247ed
Make CountWalker use COUNT(*) when $distinct is explicitly set to fal…
Jul 22, 2024
96546ca
Merge pull request #11365 from beberlei/ReintroducePartialForArrayHyd…
greg0ire Jul 24, 2024
56cd688
Remove unused $pkColumns when gathering columns (#11560)
smoothie Aug 1, 2024
121158f
GH11551 - fix OneToManyPersister::deleteEntityCollection when using
gitbugr Aug 3, 2024
2707b09
fix spacing
gitbugr Aug 3, 2024
8ac6a13
Merge pull request #11564 from gitbugr/GH11501_fix_o2m_persister_sing…
greg0ire Aug 5, 2024
3f550c1
DQL custom functions: document TypedExpression
janedbal Jul 11, 2024
205b2f5
Merge pull request #11550 from janedbal/patch-1
greg0ire Aug 9, 2024
fe4a2e8
Original entity data resolves inverse 1-1 joins
mcurland Aug 17, 2024
5f1fe15
Merge pull request #11557 from d-ph/feature/make-count-walker-use-cou…
greg0ire Aug 19, 2024
8c582a4
Add support for using nested DTOs
eltharin Aug 12, 2024
6f93ceb
Merge pull request #11576 from eltharin/newnestedDto
greg0ire Aug 19, 2024
168ac31
Merge pull request #11109 from mcurland/Fix11108
greg0ire Aug 23, 2024
3a82b15
Merge remote-tracking branch 'origin/2.19.x' into 3.2.x
greg0ire Aug 23, 2024
831a1eb
Merge pull request #11581 from greg0ire/3.2.x
greg0ire Aug 23, 2024
e1dc94d
Merge pull request #11583 from doctrine/3.2.x-merge-up-into-3.3.x_lYl…
greg0ire Aug 23, 2024
c6b2d89
Precise EntityRepository::count (#11579)
VincentLanglet Aug 24, 2024
6cde337
PHPStan 1.12 (#11585)
derrabus Aug 27, 2024
cfc0655
Fix compatibility with DBAL 4.2 (#11592)
derrabus Sep 3, 2024
5724e62
Merge pull request #11596 from doctrine/3.2.x
greg0ire Sep 5, 2024
25d5bc5
Move orphan metadata to where it belongs
greg0ire Sep 27, 2024
e6961bd
Install guides-cli as a dev requirement
greg0ire Sep 27, 2024
1bf4603
Merge pull request #11615 from greg0ire/move-orphan
greg0ire Sep 29, 2024
93ce84f
Merge pull request #11614 from greg0ire/guides-as-dep
greg0ire Sep 29, 2024
2432939
Bump doctrine/.github from 5.0.1 to 5.1.0 (#11616)
dependabot[bot] Sep 30, 2024
b7fd824
Update attributes-reference.rst
n0099 Oct 1, 2024
d18126a
Merge pull request #11618 from n0099/patch-1
greg0ire Oct 1, 2024
7f0a181
add nested new in EBNF documentation
eltharin Oct 2, 2024
434b7ce
Merge pull request #11619 from eltharin/change_EBNF
greg0ire Oct 4, 2024
b13564c
Make nullable parameters explicit in generated entities (#11625)
derrabus Oct 8, 2024
cc28fed
Replace custom directives with native option
greg0ire Oct 8, 2024
0c0c61c
Merge pull request #11627 from greg0ire/no-custom-directives
greg0ire Oct 8, 2024
44dddb2
Merge remote-tracking branch 'origin/2.19.x' into 3.2.x
greg0ire Oct 8, 2024
191a536
Merge pull request #11629 from greg0ire/3.2.x
greg0ire Oct 8, 2024
d297830
Merge remote-tracking branch 'origin/3.2.x' into 3.3.x
greg0ire Oct 9, 2024
dbf26db
Merge remote-tracking branch 'origin/3.3.x' into 4.0.x
greg0ire Oct 9, 2024
b5c0e01
Remove int from union type
greg0ire Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ on:

jobs:
coding-standards:
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.0.1"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0"
43 changes: 7 additions & 36 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,16 @@ on:
branches:
- "*.x"
paths:
- .github/workflows/documentation.yml
- docs/**
- ".github/workflows/documentation.yml"
- "docs/**"
push:
branches:
- "*.x"
paths:
- .github/workflows/documentation.yml
- docs/**
- ".github/workflows/documentation.yml"
- "docs/**"

jobs:
validate-with-guides:
name: "Validate documentation with phpDocumentor/guides"
runs-on: "ubuntu-22.04"

steps:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"

- name: "Remove existing composer file"
run: "rm composer.json"

- name: "Require phpdocumentor/guides-cli"
run: "composer require --dev phpdocumentor/guides-cli --no-update"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

- name: "Add orphan metadata where needed"
run: |
printf '%s\n\n%s\n' ":orphan:" "$(cat docs/en/sidebar.rst)" > docs/en/sidebar.rst
printf '%s\n\n%s\n' ":orphan:" "$(cat docs/en/reference/installation.rst)" > docs/en/reference/installation.rst

- name: "Run guides-cli"
run: "vendor/bin/guides -vvv --no-progress docs/en 2>&1 | grep -v 'No template found for rendering directive' | ( ! grep WARNING )"
documentation:
name: "Documentation"
uses: "doctrine/.github/.github/workflows/[email protected]"
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
release:
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.0.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.1.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
15 changes: 12 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ now they throw an exception.

## BC BREAK: Partial objects are removed

- The `PARTIAL` keyword in DQL no longer exists.
- `Doctrine\ORM\Query\AST\PartialObjectExpression`is removed.
- `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` and
WARNING: This was relaxed in ORM 3.2 when partial was re-allowed for array-hydration.

- The `PARTIAL` keyword in DQL no longer exists (reintroduced in ORM 3.2)
- `Doctrine\ORM\Query\AST\PartialObjectExpression` is removed. (reintroduced in ORM 3.2)
- `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` (reintroduced in ORM 3.2) and
`Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD` are removed.
- `Doctrine\ORM\EntityManager*::getPartialReference()` is removed.

Expand Down Expand Up @@ -779,6 +781,13 @@ following classes and methods:

Use `toIterable()` instead.

# Upgrade to 2.20

## PARTIAL DQL syntax is undeprecated for non-object hydration

Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator
that is not creating entities, such as the ArrayHydrator.

# Upgrade to 2.19

## Deprecate calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"require-dev": {
"doctrine/coding-standard": "^12.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "1.11.1",
"phpdocumentor/guides-cli": "^1.4",
"phpstan/phpstan": "1.12.0",
"phpunit/phpunit": "^10.4.0",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2",
Expand Down
27 changes: 27 additions & 0 deletions docs/en/cookbook/dql-user-defined-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,33 @@ vendors SQL parser to show us further errors in the parsing
process, for example if the Unit would not be one of the supported
values by MySql.

Typed functions
---------------
By default, result of custom functions is fetched as-is from the database driver.
If you want to be sure that the type is always the same, then your custom function needs to
implement ``Doctrine\ORM\Query\AST\TypedExpression``. Then, the result is wired
through ``Doctrine\DBAL\Types\Type::convertToPhpValue()`` of the ``Type`` returned in ``getReturnType()``.

.. code-block:: php

<?php

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\TypedExpression;

class DateDiff extends FunctionNode implements TypedExpression
{
// ...

public function getReturnType(): Type
{
return Type::getType(Types::INTEGER);
}
}


Conclusion
----------

Expand Down
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Advanced Topics
* :doc:`TypedFieldMapper <reference/typedfieldmapper>`
* :doc:`Improving Performance <reference/improving-performance>`
* :doc:`Caching <reference/caching>`
* :doc:`Partial Hydration <reference/partial-hydration>`
* :doc:`Change Tracking Policies <reference/change-tracking-policies>`
* :doc:`Best Practices <reference/best-practices>`
* :doc:`Metadata Drivers <reference/metadata-drivers>`
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/attributes-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Index
- :ref:`#[AttributeOverride] <attrref_attributeoverride>`
- :ref:`#[Column] <attrref_column>`
- :ref:`#[Cache] <attrref_cache>`
- :ref:`#[ChangeTrackingPolicy <attrref_changetrackingpolicy>`
- :ref:`#[ChangeTrackingPolicy] <attrref_changetrackingpolicy>`
- :ref:`#[CustomIdGenerator] <attrref_customidgenerator>`
- :ref:`#[DiscriminatorColumn] <attrref_discriminatorcolumn>`
- :ref:`#[DiscriminatorMap] <attrref_discriminatormap>`
Expand Down
54 changes: 51 additions & 3 deletions docs/en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,25 @@ when the DQL is switched to an arbitrary join.
- HAVING is applied to the results of a query after
aggregation (GROUP BY)


Partial Hydration Syntax
^^^^^^^^^^^^^^^^^^^^^^^^

By default when you run a DQL query in Doctrine and select only a
subset of the fields for a given entity, you do not receive objects
back. Instead, you receive only arrays as a flat rectangular result
set, similar to how you would if you were just using SQL directly
and joining some data.

If you want to select a partial number of fields for hydration entity in
the context of array hydration and joins you can use the ``partial`` DQL keyword:

.. code-block:: php

<?php
$query = $em->createQuery('SELECT partial u.{id, username}, partial a.{id, name} FROM CmsUser u JOIN u.articles a');
$users = $query->getArrayResult(); // array of partially loaded CmsUser and CmsArticle fields

"NEW" Operator Syntax
^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -560,7 +579,34 @@ And then use the ``NEW`` DQL keyword :
$query = $em->createQuery('SELECT NEW CustomerDTO(c.name, e.email, a.city, SUM(o.value)) FROM Customer c JOIN c.email e JOIN c.address a JOIN c.orders o GROUP BY c');
$users = $query->getResult(); // array of CustomerDTO

Note that you can only pass scalar expressions to the constructor.
You can also nest several DTO :

.. code-block:: php

<?php
class CustomerDTO
{
public function __construct(string $name, string $email, AddressDTO $address, string|null $value = null)
{
// Bind values to the object properties.
}
}

class AddressDTO
{
public function __construct(string $street, string $city, string $zip)
{
// Bind values to the object properties.
}
}

.. code-block:: php

<?php
$query = $em->createQuery('SELECT NEW CustomerDTO(c.name, e.email, NEW AddressDTO(a.street, a.city, a.zip)) FROM Customer c JOIN c.email e JOIN c.address a');
$users = $query->getResult(); // array of CustomerDTO

Note that you can only pass scalar expressions or other Data Transfer Objects to the constructor.

Using INDEX BY
~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1576,10 +1622,12 @@ Select Expressions

.. code-block:: php

SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable]
SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable]
SimpleSelectExpression ::= (StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression) [["AS"] AliasResultVariable]
PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet
PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}"
NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")"
NewObjectArg ::= ScalarExpression | "(" Subselect ")"
NewObjectArg ::= ScalarExpression | "(" Subselect ")" | NewObjectExpression

Conditional Expressions
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions docs/en/reference/installation.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

Installation
============

Expand Down
20 changes: 20 additions & 0 deletions docs/en/reference/partial-hydration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Partial Hydration
=================

.. note::

Creating Partial Objects through DQL was possible in ORM 2,
but is only supported for array hydration as of ORM 3.

Partial hydration of entities is allowed in the array hydrator, when
only a subset of the fields of an entity are loaded from the database
and the nested results are still created based on the entity relationship structure.

.. code-block:: php

<?php
$users = $em->createQuery("SELECT PARTIAL u.{id,name}, partial a.{id,street} FROM MyApp\Domain\User u JOIN u.addresses a")
->getArrayResult();

This is a useful optimization when you are not interested in all fields of an entity
for performance reasons, for example in use-cases for exporting or rendering lots of data.
18 changes: 18 additions & 0 deletions docs/en/reference/query-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,21 @@ same query of example 6 written using
->add('from', new Expr\From('User', 'u'))
->add('where', new Expr\Comparison('u.id', '=', '?1'))
->add('orderBy', new Expr\OrderBy('u.name', 'ASC'));

Binding Parameters to Placeholders
----------------------------------

It is often not necessary to know about the exact placeholder names when
building a query. You can use a helper method to bind a value to a placeholder
and directly use that placeholder in your query as a return value:

.. code-block:: php

<?php
// $qb instanceof QueryBuilder

$qb->select('u')
->from('User', 'u')
->where('u.email = ' . $qb->createNamedParameter($userInputEmail))
;
// SELECT u FROM User u WHERE email = :dcValue1
9 changes: 5 additions & 4 deletions docs/en/reference/working-with-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,11 @@ Performance of different deletion strategies
Deleting an object with all its associated objects can be achieved
in multiple ways with very different performance impacts.

1. If an association is marked as ``CASCADE=REMOVE`` Doctrine ORM
will fetch this association. If its a Single association it will
pass this entity to
``EntityManager#remove()``. If the association is a collection, Doctrine will loop over all its elements and pass them to``EntityManager#remove()``.
1. If an association is marked as ``CASCADE=REMOVE`` Doctrine ORM will
fetch this association. If it's a Single association it will pass
this entity to ``EntityManager#remove()``. If the association is a
collection, Doctrine will loop over all its elements and pass them to
``EntityManager#remove()``.
In both cases the cascade remove semantics are applied recursively.
For large object graphs this removal strategy can be very costly.
2. Using a DQL ``DELETE`` statement allows you to delete multiple
Expand Down
Loading
Loading