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 for Doctrine ORMv3/DBALv4 #333

Merged
merged 10 commits into from
Apr 23, 2024
Merged

Add support for Doctrine ORMv3/DBALv4 #333

merged 10 commits into from
Apr 23, 2024

Conversation

W0rma
Copy link
Contributor

@W0rma W0rma commented Apr 22, 2024

This PR is built on top of #331 and tries to fix the remaining compatibility issues.

Fixes #328

Comment on lines 24 to 36
//reset count orderBy since it can break query and slow it down
$qb
->resetQueryPart('orderBy')
;

if (method_exists($qb, 'resetOrderBy')) {
$qb->resetOrderBy();
} else {
$qb->resetQueryParts(['orderBy']);
}

// get the query
$sql = $qb->getSQL();

$qb
->resetQueryParts()
->select('count(*) as cnt')
->from('(' . $sql . ')', 'dbal_count_tbl')
;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resetQueryParts() has been removed in DBALv4.

Removing ->from() makes the test pipeline green.
However, I'm not sure if this could cause any side effects.

Without this change $qb->getSQL() would return SELECT count(*) as cnt FROM Article a, (SELECT * FROM Article a) dbal_count_tbl which would lead to the result 16 instead of 4

In master, $qb->getSQL() returns SELECT count(*) as cnt FROM (SELECT * FROM Article a) dbal_count_tbl.

@garak garak merged commit e689850 into KnpLabs:master Apr 23, 2024
7 checks passed
@W0rma W0rma deleted the doctrine3 branch April 23, 2024 08:15
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.

Add compatibility with doctrine/orm 3 and doctrine/dbal 4
2 participants