Add better error reporting to DB\IO for query with params
On error with query with params the query was sent to the server and if ther query itself is ok but there is a problem with the parameters a wrong error message ($1 not found) will be returned Add pg_last_error reporting to catch this too. Update both error reporting to return not string and prefix combined but prefix + error string in array In error return check that both strings are not equal, so we do not return the same error string twice. Also default set dbh variable in the PgSQL class to false so it will skip last error report if there is no dbh set yet. Bug fix for db query with params debug output. if there are more than 9 entries the $1 of eg $10 is replaced with $1 entry again. Changed to '#' instead '$' to avoid this. Other: ACL\Login: replace EOM with HTML config.master: replace list() with [] Add single DB tester where we can test single db calls without adding more to the general test run
This commit is contained in:
@@ -156,7 +156,7 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
$db->dbExec("DROP TABLE test_meta");
|
||||
}
|
||||
// uid is for internal reference tests
|
||||
$base_table = <<<EOM
|
||||
$base_table = <<<SQL
|
||||
uid VARCHAR,
|
||||
row_int INT,
|
||||
row_numeric NUMERIC,
|
||||
@@ -172,36 +172,36 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
row_array_varchar VARCHAR ARRAY
|
||||
)
|
||||
WITHOUT OIDS
|
||||
EOM;
|
||||
SQL;
|
||||
// create the tables
|
||||
$db->dbExec(
|
||||
// primary key name is table + '_id'
|
||||
<<<EOM
|
||||
<<<SQL
|
||||
CREATE TABLE table_with_primary_key (
|
||||
table_with_primary_key_id SERIAL PRIMARY KEY,
|
||||
$base_table
|
||||
EOM
|
||||
SQL
|
||||
/* "CREATE TABLE table_with_primary_key ("
|
||||
// primary key name is table + '_id'
|
||||
. "table_with_primary_key_id SERIAL PRIMARY KEY, "
|
||||
. $base_table */
|
||||
);
|
||||
$db->dbExec(
|
||||
<<<EOM
|
||||
<<<SQL
|
||||
CREATE TABLE table_without_primary_key (
|
||||
$base_table
|
||||
EOM
|
||||
SQL
|
||||
/* "CREATE TABLE table_without_primary_key ("
|
||||
. $base_table */
|
||||
);
|
||||
// create simple table for meta test
|
||||
$db->dbExec(
|
||||
<<<EOM
|
||||
<<<SQL
|
||||
CREATE TABLE test_meta (
|
||||
row_1 VARCHAR,
|
||||
row_2 INT
|
||||
) WITHOUT OIDS
|
||||
EOM
|
||||
SQL
|
||||
/* "CREATE TABLE test_meta ("
|
||||
. "row_1 VARCHAR, "
|
||||
. "row_2 INT"
|
||||
@@ -1342,10 +1342,10 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
'has default' => false,
|
||||
'array dims' => 0,
|
||||
'is enum' => false,
|
||||
'is base' => 1,
|
||||
'is base' => true,
|
||||
'is composite' => false,
|
||||
'is pesudo' => false,
|
||||
'description' => '',
|
||||
'is pseudo' => false
|
||||
],
|
||||
'row_2' => [
|
||||
'num' => 2,
|
||||
@@ -1355,10 +1355,10 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
'has default' => false,
|
||||
'array dims' => 0,
|
||||
'is enum' => false,
|
||||
'is base' => 1,
|
||||
'is base' => true,
|
||||
'is composite' => false,
|
||||
'is pesudo' => false,
|
||||
'description' => '',
|
||||
'is pseudo' => false
|
||||
]
|
||||
]
|
||||
],
|
||||
@@ -1374,10 +1374,10 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
'has default' => false,
|
||||
'array dims' => 0,
|
||||
'is enum' => false,
|
||||
'is base' => 1,
|
||||
'is base' => true,
|
||||
'is composite' => false,
|
||||
'is pesudo' => false,
|
||||
'description' => '',
|
||||
'is pseudo' => false
|
||||
],
|
||||
'row_2' => [
|
||||
'num' => 2,
|
||||
@@ -1387,10 +1387,10 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
'has default' => false,
|
||||
'array dims' => 0,
|
||||
'is enum' => false,
|
||||
'is base' => 1,
|
||||
'is base' => true,
|
||||
'is composite' => false,
|
||||
'is pesudo' => false,
|
||||
'description' => '',
|
||||
'is pseudo' => false
|
||||
]
|
||||
]
|
||||
],
|
||||
@@ -4425,16 +4425,16 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
]
|
||||
]
|
||||
],
|
||||
// same but as EOM
|
||||
'single insert (PK), EOM string' => [
|
||||
<<<EOM
|
||||
// same but as heredoc
|
||||
'single insert (PK), heredoc string' => [
|
||||
<<<SQL
|
||||
INSERT INTO table_with_primary_key (
|
||||
row_varchar, row_varchar_literal, row_int, row_date
|
||||
) VALUES (
|
||||
'Text', 'Other', 123, '2022-03-01'
|
||||
)
|
||||
RETURNING row_varchar, row_varchar_literal, row_int, row_date
|
||||
EOM,
|
||||
SQL,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@@ -4529,16 +4529,16 @@ final class CoreLibsDBIOTest extends TestCase
|
||||
]
|
||||
]
|
||||
],
|
||||
// same as above but as EOM string
|
||||
'single insert (No PK), EOM string' => [
|
||||
<<<EOM
|
||||
// same as above but as heredoc string
|
||||
'single insert (No PK), heredoc string' => [
|
||||
<<<SQL
|
||||
INSERT INTO table_without_primary_key (
|
||||
row_varchar, row_varchar_literal, row_int, row_date
|
||||
) VALUES (
|
||||
'Text', 'Other', 123, '2022-03-01'
|
||||
)
|
||||
RETURNING row_varchar, row_varchar_literal, row_int, row_date
|
||||
EOM,
|
||||
SQL,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
||||
Reference in New Issue
Block a user