summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Flatz2018-10-08 15:34:35 +0200
committerDavid Flatz2018-10-08 15:34:35 +0200
commite86a9a9ffc312e1f1b239ea4ec3d2b613a065a10 (patch)
treec654cb5168a00d80cac06a432cdd8971e623d9c5
parent9e9565b9b29696bae8f74e02b0457208380caaef (diff)
downloaditools-e86a9a9ffc312e1f1b239ea4ec3d2b613a065a10.tar.gz
itools-e86a9a9ffc312e1f1b239ea4ec3d2b613a065a10.tar.bz2
itools-e86a9a9ffc312e1f1b239ea4ec3d2b613a065a10.zip
improve tests and styling
-rw-r--r--it_dbi.class6
-rwxr-xr-xtest/it_dbi.t3
2 files changed, 6 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 004c22d..76f4d1a 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -264,7 +264,8 @@ function _set($tags, $force = false)
{
if (substr($field, 0, 1) === "-")
$newdyns[] = "'\$.$f', " . $value;
- else if ($force || isset($value) && isset($dyndata[$f]) ? strval($value) !== strval($dyndata[$f]) : $value !== $dyndata[$f] || !array_key_exists($f, $dyndata)) {
+ else if ($force || isset($value) && isset($dyndata[$f]) ? strval($value) !== strval($dyndata[$f]) : $value !== $dyndata[$f] || !array_key_exists($f, $dyndata))
+ {
if (is_null($value))
$deldyns[] = "'\$.$f'";
else
@@ -284,7 +285,8 @@ function _set($tags, $force = false)
{
if ($force == "insert") # INSERT/REPLACE
$result[] = "dyncols = JSON_OBJECT(" . join(", ", (array)$alldyns) . ")";
- else if ($newdyns || $deldyns) {
+ else if ($newdyns || $deldyns)
+ {
$source = $this->_dyndata ? 'dyncols' : '"{}"';
if ($newdyns)
$source = "JSON_SET($source, " . join(', ', $newdyns) . ')';
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 6b89db2..a257105 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -366,7 +366,8 @@ is($r->key3, 'c', 'dynamic column for record with empty dyncols whould be correc
$r->clear(false);
is($r->select(['-key1 IS NOT' => 'NULL']), 1, 'only one entry has a value for key1');
-is($r->select(['-key2 IS' => 'NULL']), 2, "two entries don't have a value for key1");
+is($r->select(['-key1 IS' => 'NULL']), 2, "two entries don't have a value for key1");
+is($r->select(['key1' => null]), 2, "same behaviour without - syntax");
$r->read(1);
$r->update(['key1' => null]);
is($r->key1, null, 'setting dyncol to null should make it be null');