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

Add support of older versions of Doctrine/Dbal library #175 #176

Conversation

tworzenieweb
Copy link
Contributor

In order to provide wider support of this library for legacy projects, we should add support for legacy versions of doctrine/dbal library. In particular versions ^2.12.0|^3.0 have a bit different QueryBuilder methods available.

The other small changes are related to accessing the schema manager.

@tworzenieweb tworzenieweb force-pushed the feature/add-support-for-older-versions-of-doctrine-dbal branch 4 times, most recently from 0f6db16 to a397fac Compare August 10, 2023 20:54
@tworzenieweb
Copy link
Contributor Author

tworzenieweb commented Aug 10, 2023

I got one concern for testing, locally I am able to shuffle the doctrine/dbal version between 2 and 3 by modifying the composer.json, but in CI/CD not sure how we could achieve that.

Actually while typing, found this lib:

https://github.com/kylekatarnls/multi-tester

@dgafka
Copy link
Member

dgafka commented Aug 11, 2023

I got one concern for testing, locally I am able to shuffle the doctrine/dbal version between 2 and 3 by modifying the composer.json, but in CI/CD not sure how we could achieve that.

@tworzenieweb we are covered with this.
CI runs with prefer-lowest and prefer-stable, to ensure lowest and highest possible stable versions :)
Screenshot from 2023-08-11 08-30-25

@dgafka
Copy link
Member

dgafka commented Aug 11, 2023

Can you fix the compatibility in main composer.json? This allows to run Monorepo tests with same range of versions as each package has :)

*
* @see https://github.com/doctrine/dbal/blob/3.6.x/UPGRADE.md#upgrade-to-31
*/
final class QueryBuilderProxy extends QueryBuilder
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to extend QueryBuilder? If they will put final on the class, this will break.

I am fine with Ecotone's abstraction which will hide the QueryBuilder inside :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sadly there is no interface to implement to duck type, because some tests are creating QB instance and got a return type defined to be QueryBuilder from Doctrine/Dbal. We could of course change that if you like.

    private function getDocumentsFor(string $collectionName): \Doctrine\DBAL\Query\QueryBuilder
    {
        return (new QueryBuilderProxy($this->getConnection()->createQueryBuilder()))
            ->select('document', 'document_type')
            ->from($this->getTableName())
            ->andWhere('collection = :collection')
            ->setParameter('collection', $collectionName, Types::TEXT);
    }

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see, let's keep it this way then.
I count on Dbal, that they will provide interface in case of making it final :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I think about it now, it might be also a nice starting point if doctrine/dbal 4.0 will ever be released.

@tworzenieweb tworzenieweb force-pushed the feature/add-support-for-older-versions-of-doctrine-dbal branch from a397fac to 5bbffb9 Compare August 11, 2023 07:02
@tworzenieweb
Copy link
Contributor Author

I got one concern for testing, locally I am able to shuffle the doctrine/dbal version between 2 and 3 by modifying the composer.json, but in CI/CD not sure how we could achieve that.

@tworzenieweb we are covered with this. CI runs with prefer-lowest and prefer-stable, to ensure lowest and highest possible stable versions :) Screenshot from 2023-08-11 08-30-25

nice, wasn't aware of that 👍

@dgafka dgafka merged commit f953e34 into ecotoneframework:main Aug 11, 2023
18 checks passed
@dgafka
Copy link
Member

dgafka commented Aug 11, 2023

Thanks for contribution :)

@tworzenieweb tworzenieweb deleted the feature/add-support-for-older-versions-of-doctrine-dbal branch August 11, 2023 07:48
@marmichalski
Copy link
Contributor

I got one concern for testing, locally I am able to shuffle the doctrine/dbal version between 2 and 3 by modifying the composer.json, but in CI/CD not sure how we could achieve that.

@tworzenieweb we are covered with this. CI runs with prefer-lowest and prefer-stable, to ensure lowest and highest possible stable versions :) Screenshot from 2023-08-11 08-30-25

CI runs against 3.x only (lowest as 3.6.0 to be precise), becauseof dependency on doctrine-bundle in version 2.9. DoctrineBundle 2.9.0 requires dbal 3.6.0. 😎

@dgafka
Copy link
Member

dgafka commented Aug 13, 2023

Thanks @marmichalski for taking a look on that :)

I've fixed that with #179

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

Successfully merging this pull request may close these issues.

3 participants