fix(mssql): when updating an object by id, omit the id itself
It is a useless update and id is an identity column in MSSQL, which is not updatable and throws an error if you try. This affects the following seven objects (Models): - Category - CustomFilter - Group - Project - Subtask - TaskExternalLink - User
This commit is contained in:
committed by
Frédéric Guillot
parent
29df527979
commit
3df89f9df2
@@ -170,7 +170,9 @@ class CategoryModel extends Base
|
|||||||
*/
|
*/
|
||||||
public function update(array $values)
|
public function update(array $values)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values);
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
|
return $this->db->table(self::TABLE)->eq('id', $values['id'])->save($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,9 +85,11 @@ class CustomFilterModel extends Base
|
|||||||
*/
|
*/
|
||||||
public function update(array $values)
|
public function update(array $values)
|
||||||
{
|
{
|
||||||
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
return $this->db->table(self::TABLE)
|
return $this->db->table(self::TABLE)
|
||||||
->eq('id', $values['id'])
|
->eq('id', $values['id'])
|
||||||
->update($values);
|
->update($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -132,7 +132,9 @@ class GroupModel extends Base
|
|||||||
*/
|
*/
|
||||||
public function update(array $values)
|
public function update(array $values)
|
||||||
{
|
{
|
||||||
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
|
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -483,8 +483,10 @@ class ProjectModel extends Base
|
|||||||
|
|
||||||
$this->helper->model->convertIntegerFields($values, array('priority_default', 'priority_start', 'priority_end', 'task_limit'));
|
$this->helper->model->convertIntegerFields($values, array('priority_default', 'priority_start', 'priority_end', 'task_limit'));
|
||||||
|
|
||||||
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
return $this->exists($values['id']) &&
|
return $this->exists($values['id']) &&
|
||||||
$this->db->table(self::TABLE)->eq('id', $values['id'])->save($values);
|
$this->db->table(self::TABLE)->eq('id', $values['id'])->save($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -237,7 +237,9 @@ class SubtaskModel extends Base
|
|||||||
public function update(array $values, $fireEvent = true)
|
public function update(array $values, $fireEvent = true)
|
||||||
{
|
{
|
||||||
$this->prepare($values);
|
$this->prepare($values);
|
||||||
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values);
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
|
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->save($updates);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$subtask = $this->getById($values['id']);
|
$subtask = $this->getById($values['id']);
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ class TaskExternalLinkModel extends Base
|
|||||||
public function update(array $values)
|
public function update(array $values)
|
||||||
{
|
{
|
||||||
$values['date_modification'] = time();
|
$values['date_modification'] = time();
|
||||||
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
|
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -290,7 +290,9 @@ class UserModel extends Base
|
|||||||
public function update(array $values)
|
public function update(array $values)
|
||||||
{
|
{
|
||||||
$this->prepare($values);
|
$this->prepare($values);
|
||||||
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
|
$updates = $values;
|
||||||
|
unset($updates['id']);
|
||||||
|
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updates);
|
||||||
$this->userSession->refresh($values['id']);
|
$this->userSession->refresh($values['id']);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user