propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 399 forks source link

Set connection debug mode on StandardServiceContainer through class-w… #1874

Closed mringler closed 2 years ago

mringler commented 2 years ago

Alternative implementation of https://github.com/propelorm/Propel2/pull/1873, see discussion there

codecov-commenter commented 2 years ago

Codecov Report

Merging #1874 (58d1765) into master (ba9abb9) will decrease coverage by 14.44%. The diff coverage is 71.42%.

@@              Coverage Diff              @@
##             master    #1874       +/-   ##
=============================================
- Coverage     87.61%   73.16%   -14.45%     
- Complexity     7807     7811        +4     
=============================================
  Files           227      227               
  Lines         21144    21053       -91     
=============================================
- Hits          18525    15404     -3121     
- Misses         2619     5649     +3030     
Flag Coverage Δ
5-max 73.16% <71.42%> (-14.45%) :arrow_down:
7.4 73.16% <71.42%> (-14.45%) :arrow_down:
agnostic ?
mysql 68.89% <71.42%> (-0.02%) :arrow_down:
pgsql 68.91% <71.42%> (-0.02%) :arrow_down:
sqlite 66.73% <71.42%> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...l/Runtime/Connection/ProfilerConnectionWrapper.php 0.00% <ø> (ø)
...time/ServiceContainer/StandardServiceContainer.php 44.89% <0.00%> (-41.73%) :arrow_down:
...rc/Propel/Runtime/Connection/ConnectionFactory.php 66.66% <66.66%> (-8.34%) :arrow_down:
...ctiveQuery/QueryExecutor/AbstractQueryExecutor.php 100.00% <100.00%> (ø)
...rc/Propel/Runtime/Connection/ConnectionWrapper.php 95.09% <100.00%> (-1.19%) :arrow_down:
src/Propel/Runtime/Connection/StatementWrapper.php 62.50% <100.00%> (ø)
src/Propel/Generator/Util/SchemaValidator.php 0.00% <0.00%> (-100.00%) :arrow_down:
src/Propel/Common/Config/Loader/JsonFileLoader.php 0.00% <0.00%> (-100.00%) :arrow_down:
...Propel/Runtime/Exception/FileNotFoundException.php 0.00% <0.00%> (-100.00%) :arrow_down:
...opel/Common/Pluralizer/SimpleEnglishPluralizer.php 0.00% <0.00%> (-100.00%) :arrow_down:
... and 145 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ba9abb9...58d1765. Read the comment docs.

dereuromark commented 2 years ago

I am fine with this approach As soon as we decided we should also adjust docs IMO.

mringler commented 2 years ago

Setting debug mode through the StandardServiceContainer now also allows to set the connection in profiler mode. Similarly to setting debug mode on the ConnectionWrapper, this is done through a static flag in ConnectionFactory.

This allows users to easily use profiled connections (which outputs query execution time) without having to fumble around with Propel internals. Current method is:

        /** @var ConnectionManagerSingle */
        $manager = Propel::getServiceContainer()->getConnectionManager('default');
        $config  = $manager->getConfiguration();
        $config['classname'] = ProfilerConnectionWrapper::class;
        $manager->setConfiguration($config);