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

5.x query abstract #16675

Merged
merged 5 commits into from Aug 11, 2022
Merged

5.x query abstract #16675

merged 5 commits into from Aug 11, 2022

Conversation

ADmad
Copy link
Member

@ADmad ADmad commented Aug 6, 2022

  • Make Datbase\Query abstract
  • Code cleanup

Refs #16648

@ADmad ADmad added this to the 5.0 milestone Aug 6, 2022
@ADmad ADmad marked this pull request as ready for review August 6, 2022 07:46
public function newQuery(): Query
{
return new Query($this);
}
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how big if a break this will be. There's nothing we could transform calls to newQuery() into.

Copy link
Member

Choose a reason for hiding this comment

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

We could backport the newSelectQuery() methods to 4.x and add a deprecation to newQuery(). That would let us encourage users upgrade in a reasonable timeframe.

I'm happy to take care of that when this merges.

} else {
$this->_quoteParts($query);
} elseif ($query instanceof DeleteQuery) {
$this->_quoteDelete($query);
}
Copy link
Member

Choose a reason for hiding this comment

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

should this have an else throw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Guess we could for completeness.

Copy link
Member

Choose a reason for hiding this comment

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

Could get fancy and use match.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, can use match(), still haven't got accustomed to the fact that it can use expressions for matching :).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

* @return void
*/
protected function _quoteParts(Query $query): void
protected function _quoteParts(Query $query, array $parts): void
Copy link
Member

Choose a reason for hiding this comment

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

Having the parts list separate from the Query instance doesn't feel right. When would we describe a query different than itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are just the part/clause names which need to be processed. They are different depending on the query type. The actual values for these parts are fetched from the Query itself.

Comment on lines +117 to +118
vendor/bin/phpunit tests/TestCase/Database --verbose --coverage-clover=coverage.xml
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit tests/TestCase/Database --verbose --testsuite=database
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 revert this change before merging?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not yet, I will revert it when I getting to updating the ORM once the changes to database package are done.

} else {
$this->_quoteParts($query);
} elseif ($query instanceof DeleteQuery) {
$this->_quoteDelete($query);
}
Copy link
Member

Choose a reason for hiding this comment

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

Could get fancy and use match.

@ADmad
Copy link
Member Author

ADmad commented Aug 10, 2022

Anymore feedback on this?

@markstory markstory merged commit cfdd41f into 5.x-split-queries Aug 11, 2022
@markstory markstory deleted the 5.x-query-abstract branch August 11, 2022 02: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.

None yet

3 participants