From e15143a71b985c53b15bf62d3c47e3bbce578d6d Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 25 Sep 2018 15:35:42 +0200 Subject: update single dyncols fields; workaround for mariadb < 10.2.16 no longer needed --- it_dbi.class | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'it_dbi.class') diff --git a/it_dbi.class b/it_dbi.class index 156c487..cee004a 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -263,7 +263,7 @@ function _set($tags, $force = false) if (!$this->_fields[$f] && $this->_fields['dyncols']) { if (substr($field, 0, 1) === "-") - $newdyns[] = $unquoteddyn = "'\$.$f', " . $value; + $newdyns[] = "'\$.$f', " . $value; else if ($force || isset($value) && isset($dyndata[$f]) ? strval($value) !== strval($dyndata[$f]) : $value !== $dyndata[$f] || !array_key_exists($f, $dyndata)) $newdyns[] = "'\$.$f', " . $this->escape_string($value); @@ -280,10 +280,8 @@ function _set($tags, $force = false) { if ($force == "insert") # INSERT/REPLACE $result[] = "dyncols = JSON_OBJECT(" . join(", ", (array)$alldyns) . ")"; - else if ($force || $unquoteddyn) # UPDATE with WHERE + else if ($newdyns) $result[] = "dyncols = JSON_SET(dyncols, " . join(", ", $newdyns) .")"; - else if ($newdyns) # UPDATE. Write all fields even if just one changed. FIXME 2018-10 UM this works around a JSON_SET bug - $result[] = "dyncols = " . $this->escape_string(json_encode($dyndata, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } $this->_writes += $result ? 1 : 0; -- cgit v1.2.3