summaryrefslogtreecommitdiff
path: root/test/it_dbi.t
diff options
context:
space:
mode:
authorUrban Müller2018-07-13 16:14:34 +0200
committerUrban Müller2018-07-13 16:15:54 +0200
commit2aa354bf452100bdd84e0a370865a335e7e4c6df (patch)
treea7d6ed01c4c448b0a540aa114ed3ffdd93b92ead /test/it_dbi.t
parent96b3a802ebce50be52886317645cfa7a943603f9 (diff)
downloaditools-2aa354bf452100bdd84e0a370865a335e7e4c6df.tar.gz
itools-2aa354bf452100bdd84e0a370865a335e7e4c6df.tar.bz2
itools-2aa354bf452100bdd84e0a370865a335e7e4c6df.zip
rewrite dyncols to work around mariadb bug in JSON_SET; add write optimization
Diffstat (limited to 'test/it_dbi.t')
-rwxr-xr-xtest/it_dbi.t36
1 files changed, 28 insertions, 8 deletions
diff --git a/test/it_dbi.t b/test/it_dbi.t
index ab70fae..70d7f6f 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -320,14 +320,34 @@ is(
#
# Test saving/retrieving/matching values in dynamically created columns
#
-$record = new it_dbi_test;
-$record->replace(['ID' => 5, 'key1' => "val0'"]); is($record->key1, "val0'");
-$record->update(['key1' => "val1'"], ['key1' => "val0'"]); is($record->key1, "val1'");
-$record->update(['key2' => "val2'"]); is($record->key1, "val1'"); is($record->key2, "val2'");
-$record->update(['-key3' => "2*2"]); is($record->key1, "val1'"); is($record->key2, "val2'"); is($record->key3, 4);
-$record->update(['key1' => "val0'"]); is($record->key1, "val0'"); is($record->key2, "val2'"); is($record->key3, 4);
-$record->replace(['ID' => 6, 'key4' => "val4'"]); is($record->key4, "val4'");
-$record->select(['key2' => "val2'"]); is($record->key2, "val2'"); is($record->key4, null, "clear previous fields");
+
+# REPLACE (without and with quoting)
+$r = new it_dbi_test;
+$r->replace(['ID' => 5, '-key1' => "2*2"]); is($r->key1, 4);
+$r->replace(['ID' => 5, 'key1' => "val0'"]); is($r->key1, "val0'");
+
+# UPDATE with WHERE (without and with quoting)
+$r->update(['-key1' => "2*2"], ['key1' => "val0'"]); is($r->key1, 4);
+$r->update(['key1' => "val1'"], ['key1' => "4"]); is($r->key1, "val1'");
+
+# UPDATE (without and with quoting)
+$r->update(['key1' => "val1'", 'key2' => "ö"]); is($r->key1, "val1'"); is($r->key2, "ö"); # check mariadb bug
+$r->update(['-key2' => "1*2"]); is($r->key1, "val1'"); is($r->key2, 2);
+$r->update(['key2' => "val2'"]); is($r->key1, "val1'"); is($r->key2, "val2'");
+$r->update(['-key3' => "1*3"]); is($r->key1, "val1'"); is($r->key2, "val2'"); is($r->key3, 3);
+$r->update(['key1' => "val0'"]); is($r->key1, "val0'"); is($r->key2, "val2'"); is($r->key3, 3);
+$r->update(['key1' => "val/'"]); is($r->key1, "val/'"); # check json encoding
+
+# Check for mistakenly inherited fields
+$r->replace(['ID' => 6, 'key4' => "val4'"]); is($r->key4, "val4'");
+$r->select(['key2' => "val2'"]); is($r->key2, "val2'"); is($r->key4, null, "cleared previous fields?");
+
+# Check removal of unnecessary writes
+$r->_writes = 0;
+$r->select(['ID' => 6]);
+$r->update(['key4' => "val4'"]); is($r->_writes, 0); is($r->key4, "val4'");
+$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
+$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
#
# Test tracked update