cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[Enhancement] Phalcon\Mvc\Model\Query\BuilderInterface Definition

Open kornerita opened this issue 9 years ago • 3 comments

Hi,

It would be nice to complete the BuilderInterface definition to match the intended method from Builder

The missing methods are:

distinct getDistinct andHaving since v3.2.0 orHaving since v3.2.0 betweenHaving since v3.2.0 notBetweenHaving since v3.2.0 inHaving since v3.2.0 notInHaving since v3.2.0 forUpdate offset getOffset

If someone is implementing BuilderInterface, this would break their compatibility; this would be for an incompatible version change.

This affects Phalcon v3.2.2 and before.

Regards, Federico.

kornerita avatar Aug 16 '17 17:08 kornerita

Hi,

I would like to add a question about this:

In \Phalcon\Mvc\Model\Query\Builder->inWhere the method signature is:

public function inWhere(string! expr, array! values, string! operator = BuilderInterface::OPERATOR_AND) -> <Builder>

while in \Phalcon\Mvc\Model\Query\BuilderInteface->inWhere is:

public function inWhere(string! expr, array! values, string! operator = BuilderInterface::OPERATOR_AND) -> <BuilderInterface>;

The difference is the return type.

Which one is correct?

  • The first
  • The second (my choice)
  • Both.

I believe that an class implementing an interface should preserve signature exactly like it's presented on the interface, regardless than in this case Builder is implementing BuilderInterface.

There is also the case where BuilderInterface->betweenWhere() differs from Builder->betweenWhere() -> <Builder> but specifying which type of object it returns.

Is there a default criteria for this or it's just decided by convenience case by case?

Regards, Federico.

kornerita avatar Aug 17 '17 18:08 kornerita

Closing in favor of #13855. Will revisit if the community votes for it, or in later versions.

niden avatar Feb 23 '19 22:02 niden

This has been addressed in v4

niden avatar Dec 09 '19 21:12 niden