From 15e629c9c1ef9356da92fccdb367a192dfd2fa59 Mon Sep 17 00:00:00 2001 From: Mo Sureerat Date: Thu, 3 Nov 2022 05:55:37 +0700 Subject: [PATCH] [ISSUE-17793] UUID - Fix insert error Signed-off-by: Mo Sureerat --- libraries/classes/InsertEdit.php | 2 +- test/classes/InsertEditTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index d4696751f1..bd487bb9b7 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -1746,7 +1746,7 @@ class InsertEdit if ( $editField->type === 'uuid' && ! $editField->isNull - && in_array($editField->value, ["''", '', "'uuid()'"], true) + && in_array($editField->value, ["''", '', "'uuid()'", 'uuid()'], true) ) { return 'uuid()'; } diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index 03620f1b2d..156636af3a 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -2768,6 +2768,24 @@ class InsertEditTest extends AbstractTestCase $this->assertEquals('`fld` = uuid()', $result); + // Test that the uuid function as a value uses the uuid function to generate a value + $result = $this->insertEdit->getQueryValueForUpdate( + new EditField( + 'fld', + "uuid()", + 'uuid', + false, + false, + false, + '', + null, + '', + false + ) + ); + + $this->assertEquals('`fld` = uuid()', $result); + // Test that the uuid type does not have a default value other than null when it is nullable $result = $this->insertEdit->getQueryValueForUpdate( new EditField(