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
Closed

ORM bug - search by primary key #13336

zvonchuk opened this issue Mar 28, 2018 · 2 comments
Assignees
Labels
bug A bug report status: low Low

Comments

@zvonchuk
Copy link

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
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 Stale issue - automatically closed label Jul 8, 2018
@stale stale bot closed this as completed Jul 9, 2018
@sergeyklay sergeyklay reopened this Jul 9, 2018
@stale stale bot removed the stale Stale issue - automatically closed label Jul 9, 2018
@stale stale bot added the stale Stale issue - automatically closed label Oct 7, 2018
@niden niden closed this as completed Oct 7, 2018
@niden niden reopened this Oct 7, 2018
@stale stale bot removed the stale Stale issue - automatically closed 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 mentioned this issue Feb 14, 2019
3 tasks
niden added a commit that referenced this issue Feb 16, 2019
* [4.0.x] - Added unicode flag for email filter

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

* [#13336] - Updated the changelog
@niden
Copy link
Member

niden commented Feb 16, 2019

This has been addressed

@niden niden closed this as completed Feb 16, 2019
@niden niden added the 4.0 label Jun 21, 2019
@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

4 participants