summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/it_dbi.t31
1 files changed, 26 insertions, 5 deletions
diff --git a/tests/it_dbi.t b/tests/it_dbi.t
index 1ae479f..e988fa8 100755
--- a/tests/it_dbi.t
+++ b/tests/it_dbi.t
@@ -13,7 +13,7 @@ $dbi->query('create temporary table it_dbi_test (
primary key(ID)
);');
-$record = new it_dbi($db + array('table' => "it_dbi_test"));
+$record = new it_dbi($db + array('table' => "it_dbi_test"));
$record->insert(array('x' => 42, 'foo' => null));
$record->insert(array('foo' => "bar"));
@@ -236,24 +236,45 @@ foreach ($record as $dummy_rec)
$count++;
is($count, 2, "Iterator reused");
-$record->store(array('ID' => 5, 'x' => 6));
+$GLOBALS['debug_sqllog'] = true;
+@$record->store(array('ID' => 5, 'x' => 6));
+like(
+ $record->_sqllog[1]['query'],
+ "REPLACE",
+ "store => REPLACE for new entries"
+);
$record->clear();
-$record->read(5);
+@$record->read(5);
is(
$record->x,
6,
"saving with store"
);
-$record->store(array('ID' => 5, 'x' => 7));
+$record->_sqllog = array();
+@$record->store(array('ID' => 5, 'x' => 7));
+like(
+ $record->_sqllog[1]['query'],
+ "UPDATE",
+ "store => UPDATE for existing entries"
+);
$record->clear();
-$record->read(5);
+@$record->read(5);
is(
$record->x,
7,
"updating with store"
);
+$record->_sqllog = array();
+@$record->store(array('ID' => 5, 'x' => 7));
+is(
+ $record->_sqllog[1]['query'],
+ null, # Only SELECT, no UPDATE
+ "Optimized away UPDATE with same values"
+);
+$GLOBALS['debug_sqllog'] = false;
+
# Test field localization feature
$dbi->query('create temporary table it_dbi_testlocalized (