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

ORM3 compatibility #421

Merged
merged 3 commits into from
Feb 29, 2024
Merged

ORM3 compatibility #421

merged 3 commits into from
Feb 29, 2024

Conversation

connorhu
Copy link
Contributor

No description provided.

@connorhu connorhu force-pushed the feature/orm3 branch 2 times, most recently from 5a7205e to bc0f53c Compare January 24, 2024 01:14
Copy link
Collaborator

@derrabus derrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for starting the work on this topic. I get the impression that you're trying to cover multiple topic at once. Try to keep your PR focused. For instance, dropping PHP 7 support or upgrading PHP CS Fixer should be separate PRs.

composer.json Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
.github/workflows/tests.yml Outdated Show resolved Hide resolved
src/Query/AbstractCryptParser.php Outdated Show resolved Hide resolved
@connorhu connorhu force-pushed the feature/orm3 branch 2 times, most recently from b06e4f7 to daaa858 Compare January 26, 2024 13:17
@beberlei
Copy link
Owner

@connorhu ah, i merged a PR that does some improvements to Lexer compatibility already causing a few conflicts here. Can you integrate it or is that problematic?

@connorhu
Copy link
Contributor Author

connorhu commented Jan 26, 2024

@connorhu ah, i merged a PR that does some improvements to Lexer compatibility already causing a few conflicts here. Can you integrate it or is that problematic?

@beberlei Sure, I can integrate it, because I've done those conversions too. There are still some open questions around code simplification, whether it makes sense or not, whether I should do it or not. I can make a table showing how much repetitive logic is in the code.

composer.json Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
src/Query/Mysql/Acos.php Outdated Show resolved Hide resolved
@connorhu connorhu force-pushed the feature/orm3 branch 2 times, most recently from 667230f to c7e89ff Compare February 5, 2024 13:50
src/Query/Mysql/AnyValue.php Outdated Show resolved Hide resolved
src/Types/ZendDateType.php Outdated Show resolved Hide resolved
tests/Query/DbTestCase.php Outdated Show resolved Hide resolved
tests/Query/DbTestCase.php Outdated Show resolved Hide resolved
tests/Query/DbTestCase.php Outdated Show resolved Hide resolved
tests/Query/Mysql/DateTest.php Outdated Show resolved Hide resolved
@connorhu connorhu force-pushed the feature/orm3 branch 4 times, most recently from 63f31a9 to 55ef25e Compare February 5, 2024 18:54
@connorhu connorhu marked this pull request as ready for review February 5, 2024 18:56
.github/workflows/orm2_tests.yml Outdated Show resolved Hide resolved
src/Types/CarbonDateTimeType.php Outdated Show resolved Hide resolved
tests/Query/DbTestCase.php Outdated Show resolved Hide resolved
tests/Query/Mysql/TrigTest.php Outdated Show resolved Hide resolved
@derrabus
Copy link
Collaborator

derrabus commented Feb 5, 2024

Please revert the changes you've made to the CI. We don't need them.

@derrabus
Copy link
Collaborator

derrabus commented Feb 7, 2024

Whenever you have time:

  • Please make PHPCS happy.
  • Please revert everything in the .github directory.
  • Please answer the remaining open question.

@connorhu
Copy link
Contributor Author

connorhu commented Feb 8, 2024

To answer your question I have to figure out whats going on here with the carbon.

The types for Carbon were extend from DateType, and some versions did not run tests when combined. This could also mean that 1) some versions didn't work at all, just weren't tested, 2) it would be better to extend the Type class instead 3) the testing is too permissive/incorrect.

@connorhu
Copy link
Contributor Author

connorhu commented Feb 8, 2024

Current implementation is not compatible with DBAL4.
When convertToDatabaseValue method of TimeType, DateType etc classes with DBAL<4 converts the value, it uses DateTimeInterface to check the type.
With DBAL4 it checks for DateTime.
DBA3:
https://github.com/doctrine/dbal/blob/de57e23f00c513263df93b9b10bbbb421bc9239f/src/Types/DateType.php#L49
DBAL4:
https://github.com/doctrine/dbal/blob/1a307d92f8531b0897176e95040051c7414d80a5/src/Types/DateType.php#L38

The problem here is that CarbonImmutable* types do not extend immutable DBAL types. If I fix this, then 4 tests still won't run because they try to save an Immutable type in an non Immutable field:

$entity->date = CarbonImmutable::createFromDate(2015, 1, 1);

If we want these 4 tests to run, we need our own convertToDatabaseValue implementation.

@connorhu
Copy link
Contributor Author

connorhu commented Feb 9, 2024

PR rebased, squasd into one commit. Now we have to wait for release ORM 2.19.0.

composer.json Outdated Show resolved Hide resolved
Co-authored-by: Alexander M. Turek <me@derrabus.de>
@derrabus
Copy link
Collaborator

derrabus commented Feb 9, 2024

Yes. Thank you very much!

@connorhu
Copy link
Contributor Author

connorhu commented Feb 9, 2024

Thank you for helping the process.

Co-authored-by: Théo Attali <theoattali@gmail.com>
@Cool-Programmer

This comment was marked as off-topic.

@connorhu

This comment was marked as off-topic.

@derrabus

This comment was marked as off-topic.

@Cool-Programmer

This comment was marked as off-topic.

@connorhu

This comment was marked as off-topic.

@derrabus

This comment was marked as off-topic.

@abozhinov
Copy link

When to expect the new release?

@derrabus
Copy link
Collaborator

When it's ready.

@connorhu
Copy link
Contributor Author

connorhu commented Feb 29, 2024

@derrabus I was thinking. It is a legitimate wish to use the code with orm3. Which is ready anyway. What if you make an orm3 branch, apply the contents of this PR as a patch, rewrite the requirement for orm3 only and put a note in the install description that until 2.19 is released, the ORM3 compatible code is there? If 2.19 is released, we will merge this PR, drop the orm3 branch and leave the master only.

@derrabus
Copy link
Collaborator

I mean, we can merge the branch as is. It's ready anyway and Composer will take care that this package is not installed with ORM 2.18.

@derrabus derrabus changed the title orm3 compatibility ORM3 compatibility Feb 29, 2024
@derrabus derrabus merged commit e1b95aa into beberlei:master Feb 29, 2024
8 checks passed
@derrabus
Copy link
Collaborator

Ah well, we should've done a rebase before, to have PHPStan analyze your changes. I've pushed b6349f3 in order to make the CI green.

@connorhu connorhu deleted the feature/orm3 branch February 29, 2024 16:11
@Chris53897
Copy link
Contributor

Thanks. But we should not forget to remove the @dev after the stable release of doctrine/orm 2.19.
https://github.com/beberlei/DoctrineExtensions/blob/master/composer.json#L13

@derrabus
Copy link
Collaborator

derrabus commented Mar 2, 2024

Sure. Not that it has any impact downstream, but we will remove it.

@derrabus
Copy link
Collaborator

derrabus commented Mar 3, 2024

https://github.com/beberlei/DoctrineExtensions/releases/tag/v1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants