I'm doing some validation of a model, and the Uniqueness validator is creating a weird query.
My custom validation()
method looks like this:
public function validation(){
$Validator = new Validation();
$Validator->add(
'name',
new Uniqueness(['message'=>'An Event Type with that name already exists.'])
);
return $this->validate($Validator);
}
The model is "EventType".
When I check the query log after validating a model with the name "CourseAdd", this is the query that gets generated:
SELECT
COUNT(*) AS `rowcount`
FROM
`event_type`
WHERE
`event_type`.`name` = 'CourseAdd' AND
`event_type`.`name` <> 'CourseAdd'
Of course that returns 0, so the validation passes - even though there's already a record with a name
of 'CourseAdd'.
I don't know of any reason why the query should be built like that, so I'm guessing it's a Phalcon bug - but I thought I'd ask here first.