Polish changes following #3305
Also add support for field comments in PostgreSQL & Oracle ... only via alter_table() for now :/
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 282e2d1..1088c03 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -88,7 +88,7 @@
*
* @var string
*/
- protected $_null = 'NULL';
+ protected $_null = 'NULL';
// --------------------------------------------------------------------
@@ -185,7 +185,6 @@
$extra_clause = ' FIRST';
}
- $comment_clause = isset($field['comment']) ? ' COMMENT ' . $field['comment'] : '';
return $this->db->escape_identifiers($field['name'])
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
@@ -195,7 +194,7 @@
.$field['default']
.$field['auto_increment']
.$field['unique']
- .$comment_clause
+ .(empty($field['comment']) ? '' : ' COMMENT '.$field['comment'])
.$extra_clause;
}
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 38f6249..24dc2b2 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -90,7 +90,7 @@
*
* @var string
*/
- protected $_null = 'NULL';
+ protected $_null = 'NULL';
// --------------------------------------------------------------------
@@ -187,8 +187,6 @@
$extra_clause = ' FIRST';
}
- $comment_clause = isset($field['comment']) ? ' COMMENT ' . $field['comment'] : '';
-
return $this->db->escape_identifiers($field['name'])
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
@@ -197,7 +195,7 @@
.$field['default']
.$field['auto_increment']
.$field['unique']
- .$comment_clause
+ .(empty($field['comment']) ? '' : ' COMMENT '.$field['comment'])
.$extra_clause;
}
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 433692d..3576a9c 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -106,6 +106,14 @@
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_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
index 2e988c3..81b2a7e 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 @@
*
* @var string
*/
- protected $_null = 'NULL';
+ protected $_null = 'NULL';
// --------------------------------------------------------------------
@@ -209,7 +209,7 @@
.$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 d4f33e1..ecbc887 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 @@
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 00579aa..66fcc76 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 @@
*
* @var string
*/
- protected $_null = 'NULL';
+ protected $_null = 'NULL';
// --------------------------------------------------------------------
@@ -144,6 +144,13 @@
$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 @@
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$field['type'] = ($field['type'] === 'NUMERIC')
- ? 'BIGSERIAL'
- : 'SERIAL';
+ ? 'BIGSERIAL'
+ : 'SERIAL';
}
}
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 1dcd027..874c205 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -70,7 +70,7 @@
*
* @var string
*/
- protected $_null = 'NULL';
+ protected $_null = 'NULL';
// --------------------------------------------------------------------
@@ -139,6 +139,13 @@
$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;
@@ -190,8 +197,8 @@
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$field['type'] = ($field['type'] === 'NUMERIC')
- ? 'BIGSERIAL'
- : 'SERIAL';
+ ? 'BIGSERIAL'
+ : 'SERIAL';
}
}