diff options
Diffstat (limited to 'test/it_dbi.t')
-rwxr-xr-x | test/it_dbi.t | 36 |
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 |