diff options
author | Andrey Andreev <narf@devilix.net> | 2014-11-03 21:45:28 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-11-03 21:45:28 +0100 |
commit | 5289f27c07bfb1d961317de351c4819f25dd5f2e (patch) | |
tree | da7f7e1a9df24b917e5447d443da5cd9cef1443a /system/database/drivers/pdo/subdrivers | |
parent | 288e95dbdcd1c4e4144861919090075b4661f330 (diff) |
Polish changes following #3305
Also add support for field comments in PostgreSQL & Oracle ... only via alter_table() for now :/
Diffstat (limited to 'system/database/drivers/pdo/subdrivers')
3 files changed, 20 insertions, 5 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php index 2e988c3f5..81b2a7e19 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php @@ -102,7 +102,7 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge { * * @var string */ - protected $_null = 'NULL'; + protected $_null = 'NULL'; // -------------------------------------------------------------------- @@ -209,7 +209,7 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge { .$field['default'] .$field['auto_increment'] .$field['unique'] - .$comment_clause + .(empty($field['comment']) ? '' : ' COMMENT '.$field['comment']) .$extra_clause; } diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php index d4f33e144..ecbc887a0 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php @@ -106,6 +106,14 @@ class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge { else { $field[$i]['_literal'] = "\n\t".$this->_process_column($field[$i]); + + if ( ! empty($field[$i]['comment'])) + { + $sqls[] = 'COMMENT ON COLUMN ' + .$this->db->escape_identifiers($table).'.'.$this->db->escape_identifiers($field[$i]['name']) + .' IS '.$field[$i]['comment']; + } + if ($alter_type === 'MODIFY' && ! empty($field[$i]['new_name'])) { $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php index 00579aab4..66fcc761a 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php @@ -75,7 +75,7 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge { * * @var string */ - protected $_null = 'NULL'; + protected $_null = 'NULL'; // -------------------------------------------------------------------- @@ -144,6 +144,13 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge { $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) .' TO '.$this->db->escape_identifiers($field[$i]['new_name']); } + + if ( ! empty($field[$i]['comment'])) + { + $sqls[] = 'COMMENT ON COLUMN ' + .$this->db->escape_identifiers($table).'.'.$this->db->escape_identifiers($field[$i]['name']) + .' IS '.$field[$i]['comment']; + } } return $sqls; @@ -195,8 +202,8 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge { if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) { $field['type'] = ($field['type'] === 'NUMERIC') - ? 'BIGSERIAL' - : 'SERIAL'; + ? 'BIGSERIAL' + : 'SERIAL'; } } |