summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2019-11-25 10:41:53 +0100
committerGitHub <noreply@github.com>2019-11-25 10:41:53 +0100
commit0db8b60492cc98ef3c85b986fc11e9dac6d7ca6c (patch)
treeccb4b6f078beb3fa0617a0cc4f0269f0bd03d921 /system/database
parentf40d86c54fbbc3adc8c901fa4580dbcb5d89a3b4 (diff)
parent187c8833635f67c5891e3fb365561f82d5a50dc2 (diff)
[ci skip] Merge pull request #5856 from ytetsuro/fix/oracle12.1-support-auto-increment
Enhancement oracle dbforge, auto_increment can be used when using oracle 12.1.
Diffstat (limited to 'system/database')
-rw-r--r--system/database/drivers/oci8/oci8_forge.php24
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_oci_driver.php4
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_oci_forge.php26
3 files changed, 50 insertions, 4 deletions
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 58f3c3913..a73899888 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -159,7 +159,29 @@ class CI_DB_oci8_forge extends CI_DB_forge {
*/
protected function _attr_auto_increment(&$attributes, &$field)
{
- // Not supported - sequences and triggers must be used instead
+ if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
+ {
+ $field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Process column
+ *
+ * @param array $field
+ * @return string
+ */
+ protected function _process_column($field)
+ {
+ return $this->db->escape_identifiers($field['name'])
+ .' '.$field['type'].$field['length']
+ .$field['unsigned']
+ .$field['default']
+ .$field['auto_increment']
+ .$field['null']
+ .$field['unique'];
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php
index dba49585c..41f7a6485 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php
@@ -142,9 +142,9 @@ class CI_DB_pdo_oci_driver extends CI_DB_pdo_driver {
}
$version_string = parent::version();
- if (preg_match('#Release\s(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
+ if (preg_match('#(Release\s)?(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
{
- return $this->data_cache['version'] = $match[1];
+ return $this->data_cache['version'] = $match['version'];
}
return FALSE;
diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
index b5d3eb143..aa78461df 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
@@ -150,9 +150,33 @@ class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge {
*/
protected function _attr_auto_increment(&$attributes, &$field)
{
- // Not supported - sequences and triggers must be used instead
+ if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
+ {
+ $field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Process column
+ *
+ * @param array $field
+ * @return string
+ */
+ protected function _process_column($field)
+ {
+ return $this->db->escape_identifiers($field['name'])
+ .' '.$field['type'].$field['length']
+ .$field['unsigned']
+ .$field['default']
+ .$field['auto_increment']
+ .$field['null']
+ .$field['unique'];
}
+ // --------------------------------------------------------------------
+
/**
* Field attribute TYPE
*