From 55530fa58824bf33281a4ee7b7c9527d9dcbf982 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 18 Apr 2025 20:01:58 +0200 Subject: [PATCH] Fix intervention update sql error (#33916) --- htdocs/fichinter/class/fichinter.class.php | 2 +- test/phpunit/FichinterTest.php | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index cd41d10a18d..5f50252fc06 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -448,7 +448,7 @@ class Fichinter extends CommonObject $sql .= ", date_valid = ".($this->datev ? "'".$this->db->idate($this->datev)."'" : "null"); } if (isset($this->datet)) { - $sql .= ", datet = '".($this->datet ? "'".$this->db->idate($this->datet)."'" : "null"); + $sql .= ", datet = ".($this->datet ? "'".$this->db->idate($this->datet)."'" : "null"); } $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index ad4879eb335..14186844122 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -104,6 +104,29 @@ class FichinterTest extends CommonClassTest return $localobject; } + /** + * testFichinterUpdate + * + * Check that a intervention object can be updated. + * + * @param Object $localobject An existing intervention object to update. + * @return Intervention object with data fetched and description changed + * + * @depends testFichinterFetch + */ + public function testFichinterUpdate($localobject) + { + global $user; + + $localobject->description = "foobar"; + + $result = $localobject->update($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, $localobject->errorsToString()); + + return $localobject; + } + /** * testFichinterValid *