diff options
author | Urban Müller | 2018-09-25 15:35:42 +0200 |
---|---|---|
committer | Urban Müller | 2018-09-25 15:35:42 +0200 |
commit | e15143a71b985c53b15bf62d3c47e3bbce578d6d (patch) | |
tree | 34275c07867ae7f0bf20d4d60997eaf16c45c9dd | |
parent | 59556a4e21632543095c895f6693dfae78c710da (diff) | |
download | itools-e15143a71b985c53b15bf62d3c47e3bbce578d6d.tar.gz itools-e15143a71b985c53b15bf62d3c47e3bbce578d6d.tar.bz2 itools-e15143a71b985c53b15bf62d3c47e3bbce578d6d.zip |
update single dyncols fields; workaround for mariadb < 10.2.16 no longer needed
-rw-r--r-- | it_dbi.class | 6 |
1 files changed, 2 insertions, 4 deletions
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; |