Skip to content

setLimit(1) not working #1010

@mkrecek234

Description

@mkrecek234

Steps to reproduce:

  1. Select any model and add some conditions which result in multiple records. Optionally also setOrder.
  2. Apply setLimit(1) to restrict to one record only
  3. Then tryLoadOne()

I get this error: Atk4\Data\Exception: Ambiguous conditions, more than one record can be loaded
Code snippet:

$customermodel = new \Atk4\Data\Model\Customer($db);
$customermodel->addCondition(\Atk4\Data\Model\Scope::CreateOr(['phone', 'LIKE', '%'.$number.'%'], ['mobile', 'LIKE', '%'.$number.'%']));
$customermodel->setOrder(['id']);
$customermodel->setLimit(1);
$entity = $customermodel->tryLoadOne();

What should be expected:
If there was minimum one entity matching the conditions, $entity should contain that (first) one, otherwise $entity == null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions