Skip to content

Commit 0db8b60

Browse files
authored
[ci skip] Merge pull request bcit-ci#5856 from ytetsuro/fix/oracle12.1-support-auto-increment
Enhancement oracle dbforge, auto_increment can be used when using oracle 12.1.
2 parents f40d86c + 187c883 commit 0db8b60

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

system/database/drivers/oci8/oci8_forge.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,29 @@ protected function _alter_table($alter_type, $table, $field)
159159
*/
160160
protected function _attr_auto_increment(&$attributes, &$field)
161161
{
162-
// Not supported - sequences and triggers must be used instead
162+
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
163+
{
164+
$field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
165+
}
166+
}
167+
168+
// --------------------------------------------------------------------
169+
170+
/**
171+
* Process column
172+
*
173+
* @param array $field
174+
* @return string
175+
*/
176+
protected function _process_column($field)
177+
{
178+
return $this->db->escape_identifiers($field['name'])
179+
.' '.$field['type'].$field['length']
180+
.$field['unsigned']
181+
.$field['default']
182+
.$field['auto_increment']
183+
.$field['null']
184+
.$field['unique'];
163185
}
164186

165187
// --------------------------------------------------------------------

system/database/drivers/pdo/subdrivers/pdo_oci_driver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ public function version()
142142
}
143143

144144
$version_string = parent::version();
145-
if (preg_match('#Release\s(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
145+
if (preg_match('#(Release\s)?(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
146146
{
147-
return $this->data_cache['version'] = $match[1];
147+
return $this->data_cache['version'] = $match['version'];
148148
}
149149

150150
return FALSE;

system/database/drivers/pdo/subdrivers/pdo_oci_forge.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,33 @@ protected function _alter_table($alter_type, $table, $field)
150150
*/
151151
protected function _attr_auto_increment(&$attributes, &$field)
152152
{
153-
// Not supported - sequences and triggers must be used instead
153+
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
154+
{
155+
$field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
156+
}
157+
}
158+
159+
// --------------------------------------------------------------------
160+
161+
/**
162+
* Process column
163+
*
164+
* @param array $field
165+
* @return string
166+
*/
167+
protected function _process_column($field)
168+
{
169+
return $this->db->escape_identifiers($field['name'])
170+
.' '.$field['type'].$field['length']
171+
.$field['unsigned']
172+
.$field['default']
173+
.$field['auto_increment']
174+
.$field['null']
175+
.$field['unique'];
154176
}
155177

178+
// --------------------------------------------------------------------
179+
156180
/**
157181
* Field attribute TYPE
158182
*

0 commit comments

Comments
 (0)