Skip to content

3.0 query abstraction #2877

Merged
merged 9 commits into from Feb 21, 2014

4 participants

@lorenzo
CakePHP member
lorenzo commented Feb 20, 2014

This moves most of Cake\ORM\Query into Cake\Datasource\QueryTrait and generalizes the code in QueryCacher to be able to cache any type of passed query.

The code inside query was rather generic as it only dealt with getting results and decorating them with one or multiple special decorators, so it was quite easy to extract without major modifications.

I'm working on a Elastic Search datasource and I've used successfully this code to build a working prototype. I was thinking in making it a cakephp official plugin, bad idea?

@josegonzalez
CakePHP member

+1 official plugin. ElasticSearch is - in my very humble opinion - everything MongoDB promised to be. Would be nice to be able to send people to something that is supported in the core :)

Tests fail in your branch, is that specific to the branch?

@ionas
ionas commented Feb 20, 2014

I didn't touch NoSQL yet, but having a stable supported official NoSQL plugin would be awesome; maybe some things are better and/or easier then.

@lorenzo
CakePHP member
lorenzo commented Feb 20, 2014

@josegonzalez only this branch, but cannot figure out what broke it. That same test runs fine in isolation

@markstory markstory commented on the diff Feb 21, 2014
src/ORM/Query.php
@@ -30,6 +29,12 @@
*/
class Query extends DatabaseQuery {
+ use QueryTrait {
+ cache as private _cache;
@markstory
CakePHP member
markstory added a note Feb 21, 2014

Why is this being changed into a private method?

@markstory
CakePHP member
markstory added a note Feb 21, 2014

Never mind, I saw why below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory markstory commented on the diff Feb 21, 2014
src/ORM/Query.php
}
+ return $this->_all();
@markstory
CakePHP member
markstory added a note Feb 21, 2014

Will other query objects have different types?

@lorenzo
CakePHP member
lorenzo added a note Feb 21, 2014

There may be no types, I don't want to force other implementations to put as much as we did into a query class as it may not make any sense. I could end up reversing this decision as I go further with the other plugin, though :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory
CakePHP member

I'm working on a Elastic Search datasource and I've used successfully this code to build a working prototype. I was thinking in making it a cakephp official plugin, bad idea?

I think having a good NoSQL datasource as a core plugin would be great. Having it would force us to be honest about the interfaces and prove that implementing other non-SQL stores with the current set of abstractions is feasible.

@lorenzo lorenzo merged commit 1ba39b9 into 3.0 Feb 21, 2014

1 check passed

Details default The Travis CI build passed
@lorenzo lorenzo deleted the 3.0-query-abstraction branch Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.