Skip to content
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

[BUG]: Method getIdentityField() not always return string #14523

Closed
Jeckerson opened this issue Nov 10, 2019 · 1 comment
Closed

[BUG]: Method getIdentityField() not always return string #14523

Jeckerson opened this issue Nov 10, 2019 · 1 comment

Comments

@Jeckerson
Copy link
Member

@Jeckerson Jeckerson commented Nov 10, 2019

Describe the bug
Not sure if bug, but according to method interface declaration it must return always the string.

public function getIdentityField(<ModelInterface> model) -> string;

But, in case, if primary key does not exist, it return false.

To Reproduce
Steps to reproduce the behavior:

 CREATE TABLE test (id INT, name VARCHAR(55));
$entity = new ModelTest();
$identityField = $this->modelsMetadata->getIdentityField($entity);
var_dump($identityField); // bool(false)

Expected behavior
Probably, return null or empty string (''), but not false.
That way assert interface contract declaration:

public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): string;

or

public function getIdentityField(\Phalcon\Mvc\ModelInterface $model): ?string;

And then return:

$entity = new ModelTest();
$identityField = $this->modelsMetadata->getIdentityField($entity);
var_dump($identityField); // null

Details

  • Phalcon version: 4.0.0-rc.2
  • PHP Version: 7.2.19
  • Operating System: Ubuntu 18
  • Installation type: Compiling from source
@niden niden added this to To do in 4.0 Release via automation Nov 11, 2019
@niden niden mentioned this issue Nov 11, 2019
5 of 5 tasks complete
niden added a commit that referenced this issue Nov 11, 2019
niden added a commit that referenced this issue Nov 11, 2019
niden added a commit that referenced this issue Nov 11, 2019
@niden niden mentioned this issue Nov 11, 2019
5 of 5 tasks complete
@niden niden moved this from To do to In progress in 4.0 Release Nov 11, 2019
niden added a commit that referenced this issue Nov 11, 2019
* niden-T14523-getidentityfield:
  [#14523] - Updated the changelog
  [#14523] - Changed the signature to return null if no identity field is present
@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Nov 11, 2019

Resolved in #14530

@niden niden closed this Nov 11, 2019
4.0 Release automation moved this from In progress to Done Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.0 Release
  
Done
2 participants
You can’t perform that action at this time.