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

ORM bug - search by primary key #13336

Closed
zvonchuk opened this Issue Mar 28, 2018 · 2 comments

Comments

Projects
4 participants
@zvonchuk
Copy link

zvonchuk commented Mar 28, 2018

Expected and Actual Behavior

When searching for a record by primary key equal to false, then ORM simply selects the first record from the table.
I think it would be more logical if ORM returned an error.

Provide minimal script to reproduce the issue

$clientId = false;
$client   = (new \CRM\Client\Client)::findFirst ($clientId);
print_r($client->toArray());

Responce:
image

Details

  • Phalcon version: 3.3.1
  • PHP Version: PHP 7.1.13-1+020180105151310.14+jessie1.gbp1086fa
  • Operating System: Debian GNU/Linux 8
  • Installation type: installing via package manager
  • Zephir version (if any): 0.10.7-2917ebe8ae
  • Server: nginx/1.12.2
  • Other related info (Database, table schema):
    mysql Ver 14.14 Distrib 5.5.55, for debian-linux-gnu (x86_64) using readline 6.3
    ENGINE=InnoDB
CREATE TABLE `client_base` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=611788 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
@JABirchall

This comment has been minimized.

Copy link

JABirchall commented Apr 9, 2018

Agreed, If the paramiter passed is not null the orm should throw an exeption if the primary key is no equal to the value passed.
While maintaining expected behavour if no value is passed or null to fetch the first row.

@stale stale bot added the stale label Jul 8, 2018

@stale stale bot closed this Jul 9, 2018

@sergeyklay sergeyklay reopened this Jul 9, 2018

@stale stale bot removed the stale label Jul 9, 2018

@stale stale bot added the stale label Oct 7, 2018

@niden niden closed this Oct 7, 2018

@niden niden reopened this Oct 7, 2018

@stale stale bot removed the stale label Oct 7, 2018

@phalcon phalcon deleted a comment from stale bot Dec 23, 2018

@phalcon phalcon deleted a comment from stale bot Dec 23, 2018

@niden niden self-assigned this Dec 23, 2018

@niden niden added this to To do in 4.0 Release via automation Dec 23, 2018

niden added a commit to niden/cphalcon that referenced this issue Feb 14, 2019

niden added a commit to niden/cphalcon that referenced this issue Feb 14, 2019

@niden niden moved this from To do to In progress in 4.0 Release Feb 14, 2019

@niden niden referenced this issue Feb 14, 2019

Merged

T13336 find first null #13826

3 of 3 tasks complete

niden added a commit that referenced this issue Feb 16, 2019

T13336 find first null (#13826)
* [4.0.x] - Added unicode flag for email filter

* [#13336] - Adjustments to handling parameters for findFirst with primary key

* [#13336] - Updated the changelog
@niden

This comment has been minimized.

Copy link
Member

niden commented Feb 16, 2019

This has been addressed

@niden niden closed this Feb 16, 2019

4.0 Release automation moved this from In progress to Done Feb 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.