summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class2
-rwxr-xr-xtests/it_dbi.t19
2 files changed, 18 insertions, 3 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 512cd4c..06e1d1e 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -246,7 +246,7 @@ function _set($tags, $allfields = false)
{
if (substr($field, 0, 1) == '-') # Unquoted value (always added)
$r[] = substr($field, 1)."=$value";
- else if ($allfields || ($value !== $this->_data[$field]))
+ else if ($allfields || (isset($value) && isset($this->_data[$field]) ? strval($value) !== strval($this->_data[$field]) : $value !== $this->_data[$field]))
{
if ($this->_p['charset'] == "utf8") # NOTE: Mysql charset is simply utf8, not utf-8
$value = it::any2utf8($value, "error in db-field $field");
diff --git a/tests/it_dbi.t b/tests/it_dbi.t
index 4a58188..ecd40e3 100755
--- a/tests/it_dbi.t
+++ b/tests/it_dbi.t
@@ -151,13 +151,28 @@ isnt(
"update with function"
);
+$record->update(array('foo' => "00"));
$rand = $record->x;
is (
- $record->_set(array('x' => $rand, 'foo' => "bar")),
- "SET `foo`='bar'",
+ $record->_set(array('x' => $rand, 'foo' => "0")),
+ "SET `foo`='0'",
'update: _set optimization'
);
+$record->update(array('foo' => NULL));
+is (
+ $record->_set('foo' => ""),
+ "SET `foo`=''",
+ 'update: _set optimization with NULL => ""'
+);
+$record->update(array('foo' => "bar"));
+$record->update(array('foo' => ""));
+is (
+ $record->_set('foo' => NULL),
+ "SET `foo`=NULL",
+ 'update: _set optimization with "" => NULL'
+);
+
$record->update(array('foo' => "bar"));
$record->select(array('foo' => "bar"));
$record->iterate();