diff options
author | George Petculescu <gxgpet@gmail.com> | 2021-10-04 18:40:47 +0200 |
---|---|---|
committer | George Petculescu <gxgpet@gmail.com> | 2021-10-04 18:40:47 +0200 |
commit | bd5fab166ccff8c0bae963cd9d83a65c226cefa2 (patch) | |
tree | 03ea4c1722febe5670561fbd535458183482e22a | |
parent | a2ccb91af9c99ff76866930b38f7abeb1345af13 (diff) |
Fixes CREATE TABLE IF NOT EXISTS on pdo_pgsql_forge; checking for dummy data DB operations result returns
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php | 7 | ||||
-rw-r--r-- | tests/mocks/database/schema/skeleton.php | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php index 187cb2d09..4c3a5aaea 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php @@ -54,6 +54,13 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge { protected $_drop_table_if = 'DROP TABLE IF EXISTS'; /** + * CREATE TABLE IF statement + * + * @var string + */ + protected $_create_table_if = 'CREATE TABLE IF NOT EXISTS'; + + /** * UNSIGNED support * * @var array diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index 888236ff3..e14aa4af4 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -76,7 +76,7 @@ class Mock_Database_Schema_Skeleton { ) )); self::$forge->add_key('id', TRUE); - self::$forge->create_table('user', TRUE); + self::$forge->create_table('user', TRUE) || show_error('Unable to create the `user` table'); // Job Table self::$forge->add_field(array( @@ -93,7 +93,7 @@ class Mock_Database_Schema_Skeleton { ) )); self::$forge->add_key('id', TRUE); - self::$forge->create_table('job', TRUE); + self::$forge->create_table('job', TRUE) || show_error('Unable to create the `job` table'); // Misc Table self::$forge->add_field(array( @@ -110,7 +110,7 @@ class Mock_Database_Schema_Skeleton { ) )); self::$forge->add_key('id', TRUE); - self::$forge->create_table('misc', TRUE); + self::$forge->create_table('misc', TRUE) || show_error('Unable to create the `misc` table'); } /** @@ -143,11 +143,11 @@ class Mock_Database_Schema_Skeleton { foreach ($data as $table => $dummy_data) { - self::$db->truncate($table); + self::$db->truncate($table) || show_error("Unable to truncate `{$table}` table"); foreach ($dummy_data as $single_dummy_data) { - self::$db->insert($table, $single_dummy_data); + self::$db->insert($table, $single_dummy_data) || show_error("Unable to insert data into `{$table}` table"); } } } |