-
Notifications
You must be signed in to change notification settings - Fork 398
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
Feature/untangle criteria class #1747
Feature/untangle criteria class #1747
Conversation
Hmm, tests fail before they even start:
I know it is what everybody says, but I don't see how this is my fault. I have not changed the phpunit.xml files. Please let me know how to proceed. |
b4bcf15
to
60889bc
Compare
Codecov Report
@@ Coverage Diff @@
## master #1747 +/- ##
============================================
+ Coverage 87.89% 87.93% +0.03%
- Complexity 7827 7870 +43
============================================
Files 267 281 +14
Lines 22546 22670 +124
============================================
+ Hits 19817 19934 +117
- Misses 2729 2736 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
b263a3e
to
a723dc3
Compare
Added test fixed from #1751. I'll remove them and rebase when that is resolved. |
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/SqlBuilder/SelectQuerySqlBuilder.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/QueryExecutor/CountQueryExecutor.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/QueryExecutor/InsertQueryExecutor.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/SqlBuilder/CountQuerySqlBuilder.php
Outdated
Show resolved
Hide resolved
a723dc3
to
b2f0f0a
Compare
105c69f
to
8c06fca
Compare
Small conflict btw. |
This is probably not going to get merged, so I am just going to close the PR. |
From what I can see it cleans up the baseline quite a bit |
Great, I have fixed the conflict |
src/Propel/Runtime/ActiveQuery/SqlBuilder/InsertQuerySqlBuilder.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/SqlBuilder/DeleteQuerySqlBuilder.php
Outdated
Show resolved
Hide resolved
src/Propel/Runtime/ActiveQuery/QueryExecutor/InsertQueryExecutor.php
Outdated
Show resolved
Hide resolved
@nederdirk can also maybe help with the review for this to be merged today? |
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
81b74e2
to
46c4303
Compare
46c4303
to
2aa9adc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not done yet, but it's lunch time for me now 😄
use Propel\Runtime\ServiceContainer\ServiceContainerInterface; | ||
use Throwable; | ||
|
||
abstract class AbstractQueryExecutor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a good opportunity to add comments about 'what is the structure of the subsystem these classes represent', i.e.
`QueryExecutor`'s responsibility is to translate a `Criteria` object to the specific RDBMS dialect and execute the query.
Use it like this: <insert example here>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments can also be added later if we don't have time now, as they are not changing the functional parts.
* @param \Propel\Runtime\ActiveQuery\Criteria $criteria | ||
* @param \Propel\Runtime\Connection\ConnectionInterface|null $con | ||
*/ | ||
public function __construct(Criteria $criteria, ?ConnectionInterface $con = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with abstract classes, it might be good to think about whether the constructor should be final
: given a class-string<AbstractQueryExecutor> $className
, should users of the Propel library be able to do new $className($criteria, $connection);
?
If concrete implementing classes (i.e. extends AbstractQueryExecutor
s) should be able to override the constructor, consider having AbstractQueryExecutor
implement an interface ConstructableQueryExecutor { function __construct(Criteria $criteria, ?ConnectionInterface $con = null); }
, so implementers are bound to that interface, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, what's the advantage here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably rediscuss this also later. Right now I am a bit concerned about the time line as this PR needs to land today for us to go into the release phase.
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
2aa9adc
to
4fc2186
Compare
src/Propel/Runtime/ActiveQuery/QueryExecutor/AbstractQueryExecutor.php
Outdated
Show resolved
Hide resolved
371c49e
to
0fd9718
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor things. Not sure if they are blocker, but IMO nice to fix
I see 1-2 important comments, otherwise we can probably continue for the beta release. |
0fd9718
to
313fac4
Compare
313fac4
to
a70d586
Compare
This one fail
looks unrelated |
Should this be a squash merge? |
One of the mysql tests always fails, but I think it is a problem with the pipeline (it's a different one each time) |
I'd prefer it |
a70d586
to
364ae31
Compare
I was in the mood for some refactoring, and decided it is time to go for the white whale, aka the
Criteria
classes.I believe those are Propel's achilles heel, since they are the center classes of ActiveQuery and parent class to all Query classes, and completely unmaintainable - with together almost 6000 lines of code, a fuzzy extension hierarchy, and them doing literally dozens of things at once.
In practice, that is acceptable, as long as everything works perfectly. But almost all bugs I have fixed were in those three classes, and I am pretty sure there are more. Also, I am pretty sure that a lot of performance is lost by hacky workarounds, of which I have seen plenty. I think those bugs and workarounds show that the information flow in those classes is not understandable anymore.
So here is a proposal to start getting things back in order by removing sql query generation and execution out of those classes. This already removes more than 500 lines of code.
The basic idea is to have the
doSelect()
,doInsert()
,do...()
methods delegate to dedicated classes. Here is an overview of the new classes (not sure if thetree
output renders in all browsers):The changes are very thoroughly tested through the Criteria classes and a few new tests.