Release 2.0.0
Changelog (since 1.1.3...2.0.0
)
- bug #295 Define
JOIN
before using the new alias from it (@peter-gribanov) - bug #294 Correct resolve context in
BaseSpecification
methods fromSatisfiable
interface (@peter-gribanov) - feature #29 Create
IsEmpty
filter (@peter-gribanov) - feature #292 Сreate
SelectNew
query modifier for use NEW Operator Syntax (@peter-gribanov) - bug #291 Allow use context in
Satisfiable
methods (@peter-gribanov) - bug #290 The context in
Operands
is optional and may not be specified (@peter-gribanov) - bug #289 Correct use custom context (@peter-gribanov)
- bug #288 Correct resolve DQL alias in context in
SelectEntity
(@peter-gribanov) - bug #287 Сorrect annotate
$context
argument intBaseSpecification::__construct()
(@peter-gribanov) - feature #286 Allow use
DISTINCT
in aggregate functions (@peter-gribanov) - feature #285 Сhange
CountDistinct
toCount
platform function (@peter-gribanov) - bug #284 Fix the
CONCAT
function declaration (@peter-gribanov) - feature #283 Iterate repository by specification with a real key from original query (@peter-gribanov)
- feature #282 Сorrect location of
BaseSpecification
class (@peter-gribanov) - feature #281 Group repository classes in
Repository
folder (@peter-gribanov) - feature #278 Allow use options in
TRIM()
platform functions (@peter-gribanov) - feature #273 Check single entity satisfiability (@peter-gribanov)
- bug #277 PHP Code Style Fixer does not check the code (@peter-gribanov)
- bug #272 Remove not used
Arithmetic::MOD
constant (@peter-gribanov) - bug #271 Remove deprecated
Modulo
arithmetic operand (@peter-gribanov) - feature #269 Update PHPStan 12 (@peter-gribanov)
- feature #268 Prefer composition over inheritance (@peter-gribanov)
- feature #267 Pedantic fixes (@peter-gribanov)
- feature #266 Add type hinting (@peter-gribanov)
- feature #265 Change access for exception classes (@peter-gribanov)
- bug #264 Mark the
BaseSpecification::getSpec()
method asabstract
(@peter-gribanov) - feature #263 Use variable-length argument lists (@peter-gribanov)
- bug #262 Remove
Happyr\DoctrineSpecification\Specification\Having
class (@peter-gribanov) - feature #260 Optimize build query in
AbstractJoin
query modifiers (@peter-gribanov) - feature #259 Update PHPSpec to 6.3 and PHP to 7.2 (@peter-gribanov)
- bug #258 Require Doctrine ORM 2.5 (@peter-gribanov)
- feature #251 Change access of
protected
properties toprivate
(@peter-gribanov) - bug #253 Build from GitHub CI fixes (@peter-gribanov)
- feature #250 Build from GitHub CI (@peter-gribanov)
- bug #247 Mark
LogicX
class asabstract
(@peter-gribanov) - bug #249 Remove deprecated
Bitwise
operands (@peter-gribanov) - bug #248 Mark
Comparison
class as abstract (@peter-gribanov) - feature #245 Declare strict types (@peter-gribanov)
- feature #246 Update Travis CI config and run CS test by PHP CS Fixer (@peter-gribanov)
Upgrade from 1.1 to 2.0
-
The
AbstractJoin::getJoinType()
method was removed. UseAbstractJoin::modifyJoin()
method inside. -
The
Comparison
class marked asabstract
. -
The
LogicX
class marked asabstract
. -
The
protected
properties inComparison
class marked asprivate
. -
The
protected
properties inIn
class marked asprivate
. -
The
protected
properties inGroupBy
class marked asprivate
. -
The
protected
properties inOrderBy
class marked asprivate
. -
The
protected
properties inLimit
class marked asprivate
. -
The
protected
properties inOffset
class marked asprivate
. -
The
Bitwise
operands was removed. -
The
Happyr\DoctrineSpecification\Specification\Having
class was removed, use
Happyr\DoctrineSpecification\Query\Having
instead. -
The
Happyr\DoctrineSpecification\EntitySpecificationRepository
class was removed, use
Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository
instead. -
The
Happyr\DoctrineSpecification\EntitySpecificationRepositoryInterface
class was removed, use
Happyr\DoctrineSpecification\Repository\EntitySpecificationRepositoryInterface
instead. -
The
Happyr\DoctrineSpecification\EntitySpecificationRepositoryTrait
class was removed, use
Happyr\DoctrineSpecification\Repository\EntitySpecificationRepositoryTrait
instead. -
The
Happyr\DoctrineSpecification\RepositoryFactory
class was removed, use
Happyr\DoctrineSpecification\Repository\RepositoryFactory
instead. -
The
Happyr\DoctrineSpecification\BaseSpecification
class was removed, use
Happyr\DoctrineSpecification\Specification\BaseSpecification
instead. -
Removes the ability to use
array
as argument for thePlatformFunction
operand.Before:
$arguments = ['create_at', new \DateTimeImmutable()]; Spec::DATE_DIFF($arguments); Spec::fun('DATE_DIFF', $arguments); new PlatformFunction('DATE_DIFF', $arguments);
After:
$arguments = ['create_at', new \DateTimeImmutable()]; Spec::DATE_DIFF(...$arguments); Spec::fun('DATE_DIFF', ...$arguments); new PlatformFunction('DATE_DIFF', ...$arguments);
-
Removes the ability to use
array
as argument for theSelect
query modifier.Before:
$fields = ['title', 'cover']; Spec::select($fields); new Select($fields);
After:
$fields = ['title', 'cover']; Spec::select(...$fields); new Select(...$fields);
-
Removes the ability to use
array
as argument for theAddSelect
query modifier.Before:
$fields = ['title', 'cover']; Spec::addSelect($fields); new AddSelect($fields);
After:
$fields = ['title', 'cover']; Spec::addSelect(...$fields); new AddSelect(...$fields);
-
The
BaseSpecification::getSpec()
method marked asabstract
. -
The
InvalidArgumentException
class marked asfinal
. -
The
LogicException
class marked asfinal
. -
The
NonUniqueResultException
class marked asfinal
. -
The
NoResultException
class marked asfinal
. -
The
UnexpectedResultException
class marked asabstract
. -
All the filter classes marked as
final
. -
All the logic classes marked as
final
. -
All the operand classes marked as
final
. -
All the query modifier classes marked as
final
. -
All the result modifier classes marked as
final
. -
The
CountOf
class marked asfinal
. -
The
DBALTypesResolver
class marked asfinal
. -
The
ValueConverter
class marked asfinal
. -
The
EntitySpecificationRepositoryTrait::getAlias()
method returns nothing else. -
The
Operand::execute()
method was added. This method performs the necessary actions on the operand and returns the
result. It is desirable to return a scalar value so that it is compatible with other operands. -
The custom platform functions also need to be made executable and register the executor in the registry.
PlatformFunction::getExecutorRegistry()->register('POW', fn ($base, $exp) => pow($base, $exp));
-
The use of DQL aliases has been replaced with descriptions of contexts.
Before:
Spec::andX( Spec::innerJoin('contestant', 'ct'), Spec::innerJoin('contest', 'c', 'ct'), Spec::innerJoin('user', 'u', 'ct'), Spec::eq('state', State::active()->value(), 'u'), Spec::eq('enabled', true, 'c') );
After:
Spec::andX( Spec::eq('contestant.user.state', State::active()->value()), Spec::eq('contestant.contest.enabled', true) );
-
Changed behavior of DQL aliases to use context.
Before:
final class PublishedQuestionnaires extends BaseSpecification { private string $contest_alias; private string $contestant_alias; private string $user_alias; public function __construct( string $contest_alias = 'c', string $contestant_alias = 'ct', string $user_alias = 'u', ?string $dql_alias = null ) { $this->contest_alias = $contest_alias; $this->contestant_alias = $contestant_alias; $this->user_alias = $user_alias; parent::__construct($dql_alias); } /** * @return Filter|QueryModifier */ protected function getSpec() { return Spec::andX( Spec::innerJoin('contestant', $this->contestant_alias), new ContestantPublished($this->contest_alias, $this->user_alias, $this->contestant_alias) ); } } final class ContestantPublished extends BaseSpecification { private string $contest_alias; private string $user_alias; public function __construct(string $contest_alias = 'c', string $user_alias = 'u', ?string $dql_alias = null) { $this->contest_alias = $contest_alias; $this->user_alias = $user_alias; parent::__construct($dql_alias); } /** * @return Filter|QueryModifier */ protected function getSpec() { return Spec::andX( new JoinedContestant($this->contest_alias, $this->user_alias), new ContestantApproved($this->contest_alias) ); } } final class ContestantApproved extends BaseSpecification implements Satisfiable { private string $contest_alias; public function __construct(string $contest_alias = 'c', ?string $dql_alias = null) { $this->contest_alias = $contest_alias; parent::__construct($dql_alias); } /** * @return Filter|QueryModifier */ protected function getSpec() { return Spec::orX( Spec::eq('permission', Permission::approved()->value()), Spec::not(new ContestRequireModeration($this->contest_alias)) ); } }
After:
final class PublishedQuestionnaires extends BaseSpecification { /** * @return Filter|QueryModifier */ protected function getSpec() { return new ContestantPublished('contestant'); } } final class ContestantPublished extends BaseSpecification { /** * @return Filter|QueryModifier */ protected function getSpec() { return Spec::andX( new JoinedContestant(), new ContestantApproved() ); } } final class ContestantApproved extends BaseSpecification implements Satisfiable { /** * @return Filter|QueryModifier */ protected function getSpec() { return Spec::orX( Spec::eq('permission', Permission::approved()->value()), Spec::not(new ContestRequireModeration('contest')) ); } }
-
The
Satisfiable
interface was added. -
The
Specification
interface was extendsSatisfiable
interface. -
The
BaseSpecification
class implementSatisfiable
interface. -
The
Happyr\DoctrineSpecification\Operand\CountDistinct
class was removed, use
Happyr\DoctrineSpecification\Operand\PlatformFunction\Count
instead. -
The
Spec::countDistinct()
method was removed, useSpec::COUNT()
instead.Before:
new CountDistinct('field_name'); Spec::countDistinct('field_name');
After:
new Count('field_name', true); Spec::COUNT('field_name', true);
-
The
COUNT
function as argument toSpec::fun()
is not longer supported, useSpec::COUNT()
instead. -
The
COUNT
function as argument toHappyr\DoctrineSpecification\Operand\PlatformFunction
is not longer supported,
useHappyr\DoctrineSpecification\Operand\PlatformFunction\Count
instead.Before:
new PlatformFunction('COUNT', 'field_name'); Spec::fun('COUNT', 'field_name');
After:
new Count('field_name'); Spec::COUNT('field_name');
-
The
AVG
function as argument toSpec::fun()
is not longer supported, useSpec::AVG()
instead. -
The
AVG
function as argument toHappyr\DoctrineSpecification\Operand\PlatformFunction
is not longer supported,
useHappyr\DoctrineSpecification\Operand\PlatformFunction\Avg
instead.Before:
new PlatformFunction('AVG', 'field_name'); Spec::fun('AVG', 'field_name');
After:
new Avg('field_name'); Spec::AVG('field_name');
-
The
MIN
function as argument toSpec::fun()
is not longer supported, useSpec::MIN()
instead. -
The
MIN
function as argument toHappyr\DoctrineSpecification\Operand\PlatformFunction
is not longer supported,
useHappyr\DoctrineSpecification\Operand\PlatformFunction\Min
instead.Before:
new PlatformFunction('MIN', 'field_name'); Spec::fun('MIN', 'field_name');
After:
new Min('field_name'); Spec::MIN('field_name');
-
The
MAX
function as argument toSpec::fun()
is not longer supported, useSpec::MAX()
instead. -
The
MAX
function as argument toHappyr\DoctrineSpecification\Operand\PlatformFunction
is not longer supported,
useHappyr\DoctrineSpecification\Operand\PlatformFunction\Max
instead.Before:
new PlatformFunction('MAX', 'field_name'); Spec::fun('MAX', 'field_name');
After:
new Max('field_name'); Spec::MAX('field_name');
-
The
SUM
function as argument toSpec::fun()
is not longer supported, useSpec::SUM()
instead. -
The
SUM
function as argument toHappyr\DoctrineSpecification\Operand\PlatformFunction
is not longer supported,
useHappyr\DoctrineSpecification\Operand\PlatformFunction\Sum
instead.Before:
new PlatformFunction('SUM', 'field_name'); Spec::fun('SUM', 'field_name');
After:
new Sum('field_name'); Spec::SUM('field_name');
-
Define
Spec::leftJoin()
,Spec::innerJoin()
andSpec::join()
before using the new alias from it.Before:
$spec = Spec::andX( Spec::select(Spec::selectEntity('person')), Spec::leftJoin('person', 'person') );
After:
$spec = Spec::andX( Spec::leftJoin('person', 'person'), Spec::select(Spec::selectEntity('person')) );