Skip to content

Conversation

@mleczakm
Copy link
Contributor

@mleczakm mleczakm commented Nov 3, 2022

Change Log

Added

  • Support for querying over joined tabled with limit/offset

Fixed

Changed

  • LimitOffsetExtractor contract

Removed

Deprecated

Security


Description

I had to query with join and iterate over chunks - modyfying DbalLimitOffsetExtractor was easiest way, I think it could be useful for everyone, and current part of lib life still allows to change contracts.

private readonly Connection $connection,
private readonly Table $table,
private readonly array $orderBy,
private readonly QueryBuilder $queryBuilder,
Copy link
Member

Choose a reason for hiding this comment

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

I must say I'm not a huge fan of this solution, there is already an existing DbalQueryExtractor that should allow you to pass custom query, the whole purpose of using DbalLimitOffsetExtractor was to simplify the most common use case where you just need to extract a single table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But does DbalQueryExtractor support chunking?

Copy link
Member

Choose a reason for hiding this comment

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

yes, its all about how you generate parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, but you have to manually query for count and manually prepare all offset-limit pairs? Looks like a lot of userland code for adding one join to query :)

Copy link
Contributor Author

@mleczakm mleczakm Dec 2, 2022

Choose a reason for hiding this comment

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

So, WDYT? Because this is real requirement from real code using this library, if you don't want to merge such extractor into lib I can make external lib for that, but I really think that it is extremely useful to be able to write such queries in extractor with small to none additional dependency (some dbal classes were already imported in this class anyway).

Copy link
Member

Choose a reason for hiding this comment

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

I have an idea, it would be a BC break but might be worth it.
What we can do is to follow your approach with QueryBuilder but then add some simple static constructor that would prepare query builder in the way current constructor works.
This way whoever will need to iterate over simple table will use static constructor and more advanced use cases would require custom query builder.

@norberttech
Copy link
Member

@mleczakm I believe that what I just merged should solve your join (and any other) problems with custom queries

@norberttech norberttech closed this Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants