Skip to content
Permalink
Browse files

Fixing nullable detection in ExistsIn rule, closes #7174

  • Loading branch information...
lorenzo committed Aug 6, 2015
1 parent c2f14ba commit 0bb29ecde8d1d8128418450f3af15d4e2be2b6b8
Showing with 11 additions and 13 deletions.
  1. +11 −13 src/ORM/Rule/ExistsIn.php
@@ -65,35 +65,33 @@ public function __invoke(EntityInterface $entity, array $options)
$this->_repository = $options['repository']->association($this->_repository);
}
if (!empty($options['_sourceTable'])) {
$source = $this->_repository instanceof Association ?
$this->_repository->target() :
$this->_repository;
if ($source === $options['_sourceTable']) {
return true;
}
$source = !empty($options['repository']) ? $options['repository'] : $this->_repository;
$source = $source instanceof Association ? $source->source() : $source;
$target = $this->_repository instanceof Association ?
$this->_repository->target() :
$this->_repository;
if (!empty($options['_sourceTable']) && $target === $options['_sourceTable']) {
return true;
}
if (!$entity->extract($this->_fields, true)) {
return true;
}
$nulls = 0;
$schema = $this->_repository->schema();
$schema = $source->schema();
foreach ($this->_fields as $field) {
if ($schema->isNullable($field) && $entity->get($field) === null) {
if ($schema->column($field) && $schema->isNullable($field) && $entity->get($field) === null) {
$nulls++;
}
}
if ($nulls === count($this->_fields)) {
return true;
}
$alias = $this->_repository->alias();
$primary = array_map(
function ($key) use ($alias) {
return "$alias.$key";
},
[$this->_repository, 'aliasField'],
(array)$this->_repository->primaryKey()
);
$conditions = array_combine(

0 comments on commit 0bb29ec

Please sign in to comment.
You can’t perform that action at this time.