Index: branches/unlabeled/unlabeled-1.30.2/core/kernel/db/dbitem.php =================================================================== diff -u -r7649 -r7725 --- branches/unlabeled/unlabeled-1.30.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 7649) +++ branches/unlabeled/unlabeled-1.30.2/core/kernel/db/dbitem.php (.../dbitem.php) (revision 7725) @@ -538,8 +538,14 @@ array_push($unique_fields,$field); foreach($unique_fields as $unique_field) { - $where[] = '`'.$unique_field.'` = '.$this->Conn->qstr( $this->GetDBField($unique_field) ); + // if field is not empty or if it is required - we add where condition + if ($this->GetDBField($unique_field) != '' || $this->Fields[$unique_field]['required']) { + $where[] = '`'.$unique_field.'` = '.$this->Conn->qstr( $this->GetDBField($unique_field) ); + } } + // This can ONLY happen if all unique fields are empty and not required. + // In such case we return true, because if unique field is not required there may be numerous empty values + if (!$where) return true; $sql = 'SELECT COUNT(*) FROM %s WHERE ('.implode(') AND (',$where).') AND ('.$this->IDField.' <> '.(int)$this->ID.')';