summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class4
-rwxr-xr-xtest/it_dbi.t2
2 files changed, 5 insertions, 1 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 00d5c99..7223904 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -269,11 +269,13 @@ function _set($tags, $force = false)
{
if (is_null($value))
$deldyns[] = "'\$.$f'";
+ if (is_int($value))
+ $newdyns[] = "'\$.$f', $value";
else
$newdyns[] = "'\$.$f', " . $this->escape_string($value);
}
- $alldyns[] = $this->escape_string($f) . ", " . (substr($field, 0, 1) === "-" ? $value : $this->escape_string($value));
+ $alldyns[] = $this->escape_string($f) . ", " . (substr($field, 0, 1) === "-" || is_int($value) ? $value : $this->escape_string($value));
$dyndata[$f] = $value;
}
else if (substr($field, 0, 1) === '-') # Unquoted value (always added)
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 45f70d4..5737404 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -323,6 +323,8 @@ is(
# 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' => 42]); is(json_encode($r->key1), json_encode(42), "Preserve type int on dyncols insert");
+$r->update(['key1' => 43]); is(json_encode($r->key1), json_encode(43), "Preserve type int on dyncols update");
$r->replace(['ID' => 5, 'key1' => "val0'"]); is($r->key1, "val0'");
# UPDATE with WHERE (without and with quoting)