Skip to content

Commit

Permalink
correct handling of unsetting relations and setting new not yet saved…
Browse files Browse the repository at this point in the history
… relations
  • Loading branch information
Hedzer committed Oct 1, 2024
1 parent 2b8ebf7 commit 5213205
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Doctrine/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,17 @@ protected function _set($fieldName, $value, $load = true)

$cd = $this->_table->getColumnDefinition($fieldName);

$isRelation = false;
foreach($this->_table->getRelations() as $name => $relation) {
if ($relation->getLocalFieldName() === $fieldName) {
$isRelation = true;
break;
}
}

$nullable = !array_key_exists('notnull', $cd) || $cd['notnull'] === false;

if (!$nullable || !is_null($value)) {
if ($value !== self::$_null && !$isRelation && (!$nullable || !is_null($value))) {
switch ($type) {
case 'json':
if (!json_validate($value)) {
Expand Down

0 comments on commit 5213205

Please sign in to comment.