summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian Schneider2021-01-25 16:15:29 +0100
committerChristian Schneider2021-01-25 16:15:29 +0100
commitedfc5b21d8df6a4209172b9288405d4c5aff4059 (patch)
tree7b1297bc3386f0f85cc5427ebed8a9b126f2e949 /test
parenta39d9275bf2fb694560eef64d0afebecf141bc28 (diff)
downloaditools-edfc5b21d8df6a4209172b9288405d4c5aff4059.tar.gz
itools-edfc5b21d8df6a4209172b9288405d4c5aff4059.tar.bz2
itools-edfc5b21d8df6a4209172b9288405d4c5aff4059.zip
Fix generating errors on SQL syntax errors, add tests for it
Diffstat (limited to 'test')
-rwxr-xr-xtest/it_dbi.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 42fae74..7b1c9d7 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -33,6 +33,13 @@ $dbi->query("create temporary table it_dbi_test (
$opts['subclass']::createclass(['table' => "it_dbi_test", 'forcecreate' => true]);
$record = new it_dbi_test;
+$GLOBALS['it_defaultconfig']['fatal_throws_exception'] = true;
+
+try {
+ is(@$record->select("SYNTAX ERROR"), "Exception", "Syntax triggers exception for fatal_throws_exception mode");
+} catch (Exception $e) {
+ is(it::match('syntax', $e->getMessage()), 'syntax', "Syntax error triggers error");
+}
$record->insert(['x' => 42, 'foo' => null]);
$record->insert(['foo' => "bar"]);
@@ -44,6 +51,12 @@ is(
"auto_increment"
);
+try {
+ @$record->insert(['ID' => 3]);
+} catch (Exception $e) {
+ is($e->getMessage(), false, "Silently ignore duplicate inserts with default safety");
+}
+
$record->read(1);
is(
[$record->_key, $record->x, $record->foo],
@@ -58,7 +71,7 @@ is(
);
is(
- $record->select(['foo <>' => ""], "LIMIT 1"),
+ @$record->select(['foo <>' => ""], "LIMIT 1"),
1,
"select with multiple parameters (LIMIT part)"
);