mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 15:02:22 +01:00
Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f18de9d569 | ||
|
|
37f76a8381 | ||
|
|
b62292256a | ||
|
|
b138395194 | ||
|
|
dede2d775a | ||
|
|
c502190712 | ||
|
|
5bff0919a7 | ||
|
|
9ef0f5301b | ||
|
|
4989ca6f15 | ||
|
|
32d1e97ce7 | ||
|
|
ca8147b148 | ||
|
|
c8ebea77f0 | ||
|
|
23f22860f1 | ||
|
|
b24586b1b5 | ||
|
|
7d8e51c934 | ||
|
|
2f8f1cfcb8 | ||
|
|
fe5ee705db | ||
|
|
0511a9f790 | ||
|
|
0e3d5e8c82 | ||
|
|
72ffb3bfbf | ||
|
|
2e9a1adc23 | ||
|
|
ffd3f50ad7 | ||
|
|
483b45d449 | ||
|
|
dd4e8fe78f | ||
|
|
7cc210424c | ||
|
|
4fd9e94819 | ||
|
|
587caf88a7 | ||
|
|
1e33b775d3 | ||
|
|
28d9472a38 | ||
|
|
c6955ec056 | ||
|
|
6863272943 | ||
|
|
c472a1535d | ||
|
|
f1a8ee175c | ||
|
|
28dd32790f | ||
|
|
ac19b21a71 | ||
|
|
a7a14cffaf | ||
|
|
ceb04bf3f6 | ||
|
|
ed9ba16ff4 | ||
|
|
fc1bf3b815 | ||
|
|
b6b342cada | ||
|
|
bea4814d55 | ||
|
|
238c15952c | ||
|
|
fdc88ba236 | ||
|
|
c49bf58682 | ||
|
|
ce844d94a0 | ||
|
|
c1f7a60c5b | ||
|
|
d1d13d5956 | ||
|
|
4f8dde2d1e | ||
|
|
e3c320c705 | ||
|
|
831232e05e | ||
|
|
a774cedb24 | ||
|
|
6b8207bb11 | ||
|
|
3d3b5b51cd | ||
|
|
760616291b | ||
|
|
8584da8fdc | ||
|
|
07bb0def60 | ||
|
|
8cf161d8bc | ||
|
|
a2990e1a0a | ||
|
|
d355c4a990 | ||
|
|
88c395c488 | ||
|
|
256d6cb0d7 | ||
|
|
a1fdc6eb6e | ||
|
|
d583460d63 | ||
|
|
79d4cfdce8 | ||
|
|
5301b99533 | ||
|
|
00c7b70211 |
2
.github/workflows/coding-standards.yml
vendored
2
.github/workflows/coding-standards.yml
vendored
@@ -24,4 +24,4 @@ on:
|
||||
|
||||
jobs:
|
||||
coding-standards:
|
||||
uses: "doctrine/.github/.github/workflows/coding-standards.yml@12.1.0"
|
||||
uses: "doctrine/.github/.github/workflows/coding-standards.yml@v12.2.0"
|
||||
|
||||
20
.github/workflows/composer-lint.yml
vendored
Normal file
20
.github/workflows/composer-lint.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: "Composer Lint"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "*.x"
|
||||
paths:
|
||||
- ".github/workflows/composer-lint.yml"
|
||||
- "composer.json"
|
||||
push:
|
||||
branches:
|
||||
- "*.x"
|
||||
paths:
|
||||
- ".github/workflows/composer-lint.yml"
|
||||
- "composer.json"
|
||||
|
||||
jobs:
|
||||
composer-lint:
|
||||
name: "Composer Lint"
|
||||
uses: "doctrine/.github/.github/workflows/composer-lint.yml@v12.2.0"
|
||||
2
.github/workflows/documentation.yml
vendored
2
.github/workflows/documentation.yml
vendored
@@ -17,4 +17,4 @@ on:
|
||||
jobs:
|
||||
documentation:
|
||||
name: "Documentation"
|
||||
uses: "doctrine/.github/.github/workflows/documentation.yml@12.1.0"
|
||||
uses: "doctrine/.github/.github/workflows/documentation.yml@v12.2.0"
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@12.1.0"
|
||||
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@v12.2.0"
|
||||
secrets:
|
||||
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
|
||||
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
|
||||
|
||||
@@ -1,32 +1,39 @@
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"type": "library",
|
||||
"description": "Object-Relational-Mapper for PHP",
|
||||
"keywords": ["orm", "database"],
|
||||
"homepage": "https://www.doctrine-project.org/projects/orm.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
|
||||
{"name": "Marco Pivetta", "email": "ocramius@gmail.com"}
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"orm",
|
||||
"database"
|
||||
],
|
||||
"scripts": {
|
||||
"docs": "composer --working-dir docs update && ./docs/vendor/bin/build-docs.sh @additional_args"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"phpstan/extension-installer": true
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "ocramius@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/orm.html",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"composer-runtime-api": "^2",
|
||||
"ext-ctype": "*",
|
||||
"composer-runtime-api": "^2",
|
||||
"doctrine/collections": "^2.2",
|
||||
"doctrine/dbal": "^3.8.2 || ^4",
|
||||
"doctrine/deprecations": "^0.5.3 || ^1",
|
||||
@@ -44,7 +51,7 @@
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpdocumentor/guides-cli": "^1.4",
|
||||
"phpstan/extension-installer": "^1.4",
|
||||
"phpstan/phpstan": "2.1.22",
|
||||
"phpstan/phpstan": "2.1.23",
|
||||
"phpstan/phpstan-deprecation-rules": "^2",
|
||||
"phpunit/phpunit": "^10.5.0 || ^11.5",
|
||||
"psr/log": "^1 || ^2 || ^3",
|
||||
@@ -55,16 +62,26 @@
|
||||
"symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Doctrine\\ORM\\": "src" }
|
||||
"psr-4": {
|
||||
"Doctrine\\ORM\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Tests\\": "tests/Tests",
|
||||
"Doctrine\\Performance\\": "tests/Performance",
|
||||
"Doctrine\\StaticAnalysis\\": "tests/StaticAnalysis",
|
||||
"Doctrine\\Performance\\": "tests/Performance"
|
||||
"Doctrine\\Tests\\": "tests/Tests"
|
||||
}
|
||||
},
|
||||
"archive": {
|
||||
"exclude": ["!vendor", "tests", "*phpunit.xml", "build.xml", "build.properties", "composer.phar", "vendor/satooshi", "lib/vendor", "*.swp"]
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"phpstan/extension-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "composer --working-dir docs update && ./docs/vendor/bin/build-docs.sh @additional_args"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ If this documentation is not helping to answer questions you have about
|
||||
Doctrine ORM don't panic. You can get help from different sources:
|
||||
|
||||
- There is a :doc:`FAQ <reference/faq>` with answers to frequent questions.
|
||||
- The `Doctrine Mailing List <https://groups.google.com/group/doctrine-user>`_
|
||||
- Slack chat room `#orm <https://www.doctrine-project.org/slack>`_
|
||||
- Report a bug on `GitHub <https://github.com/doctrine/orm/issues>`_.
|
||||
- On `StackOverflow <https://stackoverflow.com/questions/tagged/doctrine-orm>`_
|
||||
|
||||
@@ -696,12 +696,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Internal/Hydration/AbstractHydrator.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:gatherRowData\(\) should return array\{data\: array\<array\>, newObjects\?\: array\<array\{class\: ReflectionClass, args\: array, obj\: object\}\>, scalars\?\: array\} but returns array\{data\: array, newObjects\: array\<array\{class\: ReflectionClass\<object\>, args\: array, obj\?\: object\}\>, scalars\?\: non\-empty\-array\}\.$#'
|
||||
identifier: return.type
|
||||
count: 1
|
||||
path: src/Internal/Hydration/AbstractHydrator.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:getClassMetadata\(\) return type with generic class Doctrine\\ORM\\Mapping\\ClassMetadata does not specify its types\: T$#'
|
||||
identifier: missingType.generics
|
||||
@@ -822,6 +816,12 @@ parameters:
|
||||
count: 1
|
||||
path: src/Internal/HydrationCompleteHandler.php
|
||||
|
||||
-
|
||||
message: '#^Offset int\|null might not exist on array\<int, object\>\.$#'
|
||||
identifier: offsetAccess.notFound
|
||||
count: 1
|
||||
path: src/Internal/StronglyConnectedComponents.php
|
||||
|
||||
-
|
||||
message: '#^Property Doctrine\\ORM\\Internal\\StronglyConnectedComponents\:\:\$representingNodes \(array\<int, object\>\) does not accept array\<int\|string, object\>\.$#'
|
||||
identifier: assign.propertyType
|
||||
@@ -1536,6 +1536,12 @@ parameters:
|
||||
count: 1
|
||||
path: src/Mapping/LegacyReflectionFields.php
|
||||
|
||||
-
|
||||
message: '#^Strict comparison using \!\=\= between array\<string, string\> and null will always evaluate to true\.$#'
|
||||
identifier: notIdentical.alwaysTrue
|
||||
count: 1
|
||||
path: src/Mapping/ManyToManyOwningSideMapping.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Mapping\\MappedSuperclass\:\:__construct\(\) has parameter \$repositoryClass with generic class Doctrine\\ORM\\EntityRepository but does not specify its types\: T$#'
|
||||
identifier: missingType.generics
|
||||
@@ -2607,7 +2613,7 @@ parameters:
|
||||
-
|
||||
message: '#^Property Doctrine\\ORM\\Query\\Filter\\SQLFilter\:\:\$parameters \(array\<string, array\{type\: string, value\: mixed, is_list\: bool\}\>\) does not accept non\-empty\-array\<string, array\{value\: mixed, type\: Doctrine\\DBAL\\ArrayParameterType\|Doctrine\\DBAL\\ParameterType\|int\|string, is_list\: bool\}\>\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
count: 2
|
||||
path: src/Query/Filter/SQLFilter.php
|
||||
|
||||
-
|
||||
@@ -2880,12 +2886,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Tools/Console/Command/GenerateProxiesCommand.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$proxyDir of method Doctrine\\ORM\\Proxy\\ProxyFactory\:\:generateProxyClasses\(\) expects string\|null, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Tools/Console/Command/GenerateProxiesCommand.php
|
||||
|
||||
-
|
||||
message: '#^Method Doctrine\\ORM\\Tools\\Console\\Command\\MappingDescribeCommand\:\:getClassMetadata\(\) return type with generic class Doctrine\\ORM\\Mapping\\ClassMetadata does not specify its types\: T$#'
|
||||
identifier: missingType.generics
|
||||
|
||||
@@ -1668,6 +1668,11 @@ class BasicEntityPersister implements EntityPersister
|
||||
$value = [$value];
|
||||
}
|
||||
|
||||
if ($value === []) {
|
||||
$selectedColumns[] = '1=0';
|
||||
continue;
|
||||
}
|
||||
|
||||
$nullKeys = array_keys($value, null, true);
|
||||
$nonNullValues = array_diff_key($value, array_flip($nullKeys));
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\AbstractAsset;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
use Doctrine\DBAL\Schema\ComparatorConfig;
|
||||
use Doctrine\DBAL\Schema\DefaultExpression;
|
||||
use Doctrine\DBAL\Schema\DefaultExpression\CurrentDate;
|
||||
use Doctrine\DBAL\Schema\DefaultExpression\CurrentTime;
|
||||
use Doctrine\DBAL\Schema\DefaultExpression\CurrentTimestamp;
|
||||
use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor;
|
||||
use Doctrine\DBAL\Schema\Index;
|
||||
use Doctrine\DBAL\Schema\Index\IndexedColumn;
|
||||
@@ -18,6 +22,7 @@ use Doctrine\DBAL\Schema\NamedObject;
|
||||
use Doctrine\DBAL\Schema\PrimaryKeyConstraint;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\AssociationMapping;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
@@ -46,6 +51,7 @@ use function count;
|
||||
use function current;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function interface_exists;
|
||||
use function is_numeric;
|
||||
use function method_exists;
|
||||
use function preg_match;
|
||||
@@ -489,6 +495,37 @@ class SchemaTool
|
||||
// the 'default' option can be overwritten here
|
||||
$options = $this->gatherColumnOptions($mapping) + $options;
|
||||
|
||||
if (isset($options['default']) && interface_exists(DefaultExpression::class)) {
|
||||
if (
|
||||
in_array($mapping->type, [
|
||||
Types::DATETIME_MUTABLE,
|
||||
Types::DATETIME_IMMUTABLE,
|
||||
Types::DATETIMETZ_MUTABLE,
|
||||
Types::DATETIMETZ_IMMUTABLE,
|
||||
], true)
|
||||
&& $options['default'] === $this->platform->getCurrentTimestampSQL()
|
||||
) {
|
||||
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentTimestamp exists as well) */
|
||||
$options['default'] = new CurrentTimestamp();
|
||||
}
|
||||
|
||||
if (
|
||||
in_array($mapping->type, [Types::TIME_MUTABLE, Types::TIME_IMMUTABLE], true)
|
||||
&& $options['default'] === $this->platform->getCurrentTimeSQL()
|
||||
) {
|
||||
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentTime exists as well) */
|
||||
$options['default'] = new CurrentTime();
|
||||
}
|
||||
|
||||
if (
|
||||
in_array($mapping->type, [Types::DATE_MUTABLE, Types::DATE_IMMUTABLE], true)
|
||||
&& $options['default'] === $this->platform->getCurrentDateSQL()
|
||||
) {
|
||||
/** @phpstan-ignore class.notFound (if DefaultExpression exists, CurrentDate exists as well) */
|
||||
$options['default'] = new CurrentDate();
|
||||
}
|
||||
}
|
||||
|
||||
if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() === [$mapping->fieldName]) {
|
||||
$options['autoincrement'] = true;
|
||||
}
|
||||
|
||||
43
tests/Tests/ORM/Functional/DefaultTimeExpressionTest.php
Normal file
43
tests/Tests/ORM/Functional/DefaultTimeExpressionTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
class DefaultTimeExpressionTest extends OrmFunctionalTestCase
|
||||
{
|
||||
use VerifyDeprecations;
|
||||
|
||||
public function testUsingTimeRelatedDefaultExpressionCausesNoDbalDeprecation(): void
|
||||
{
|
||||
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7195');
|
||||
|
||||
$this->createSchemaForModels(TimeEntity::class);
|
||||
}
|
||||
}
|
||||
|
||||
#[ORM\Entity]
|
||||
class TimeEntity
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column]
|
||||
public int $id;
|
||||
|
||||
#[ORM\Column(options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||
public DateTime $createdAt;
|
||||
|
||||
#[ORM\Column(options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||
public DateTimeImmutable $createdAtImmutable;
|
||||
|
||||
#[ORM\Column(options: ['default' => 'CURRENT_TIME'])]
|
||||
public DateTime $createdTime;
|
||||
|
||||
#[ORM\Column(options: ['default' => 'CURRENT_DATE'])]
|
||||
public DateTime $createdDate;
|
||||
}
|
||||
54
tests/Tests/ORM/Functional/Ticket/GH12254Test.php
Normal file
54
tests/Tests/ORM/Functional/Ticket/GH12254Test.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\GeneratedValue;
|
||||
use Doctrine\ORM\Mapping\Id;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
class GH12254Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema([
|
||||
GH12254EntityA::class,
|
||||
]);
|
||||
|
||||
$this->_em->persist(new GH12254EntityA());
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public function testFindByEmptyArrayShouldReturnEmptyArray(): void
|
||||
{
|
||||
// pretend we are starting afresh
|
||||
$this->_em = $this->getEntityManager();
|
||||
$result = $this->_em->getRepository(GH12254EntityA::class)->findBy(['id' => []]);
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testFindByInNullableField(): void
|
||||
{
|
||||
$this->_em = $this->getEntityManager();
|
||||
$result = $this->_em->getRepository(GH12254EntityA::class)->findBy(['name' => []]);
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
}
|
||||
|
||||
#[Entity]
|
||||
class GH12254EntityA
|
||||
{
|
||||
#[Column(type: 'integer')]
|
||||
#[Id]
|
||||
#[GeneratedValue(strategy: 'AUTO')]
|
||||
public int $id;
|
||||
|
||||
#[Column(type: 'string', nullable: true)]
|
||||
public string|null $name = null;
|
||||
}
|
||||
@@ -147,6 +147,7 @@ class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase
|
||||
}
|
||||
|
||||
#[Group('DDC-3056')]
|
||||
#[Group('GH12254')]
|
||||
public function testSelectConditionStatementWithMultipleValuesContainingNull(): void
|
||||
{
|
||||
self::assertEquals(
|
||||
@@ -168,6 +169,11 @@ class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase
|
||||
'(t0.id IN (?, ?) OR t0.id IS NULL)',
|
||||
$this->persister->getSelectConditionStatementSQL('id', [123, null, 234]),
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
'1=0',
|
||||
$this->persister->getSelectConditionStatementSQL('id', []),
|
||||
);
|
||||
}
|
||||
|
||||
public function testCountCondition(): void
|
||||
|
||||
Reference in New Issue
Block a user