summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-22 12:12:22 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-22 12:12:22 +0100
commit7ade8b7944d10f4fd1583789309cf003a3eac6f7 (patch)
treeb5b305d5d8ffb781682914a40f19ae8aa9dac477 /system/database/drivers/pdo
parent2eaeee5aa3971932e58ffac48554e554d799249f (diff)
Fix modify_column() issues (#2020)
Diffstat (limited to 'system/database/drivers/pdo')
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php10
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php11
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php2
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_oci_forge.php2
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php13
5 files changed, 18 insertions, 20 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
index e8421ec41..cb7d9e697 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
@@ -108,12 +108,8 @@ class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge {
}
else
{
- $sqls[] = $sql.' CHANGE '.$this->_process_column($field[$i]);
- if ( ! empty($field[$i]['new_name']))
- {
- $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
- .' AS '.$this->db->escape_identifiers($field[$i]['name']);
- }
+ $alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE ';
+ $sqls[] = $sql.$alter_type.$this->_process_column($field[$i]);
}
}
@@ -139,7 +135,7 @@ class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge {
}
return $this->db->escape_identifiers($field['name'])
- .(empty($field['new_name']) ? '' : $this->db->escape_identifiers($field['new_name']))
+ .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
.$field['unsigned']
.$field['null']
diff --git a/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php b/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php
index 474188f4e..7b86de97f 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php
@@ -123,7 +123,7 @@ class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
$sqls = array();
- for ($i = 0, $c = count($field), $sql .= $alter_type.' '; $i < $c; $i++)
+ for ($i = 0, $c = count($field); $i < $c; $i++)
{
if ($field[$i]['_literal'] !== FALSE)
{
@@ -132,13 +132,14 @@ class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
if (isset($field[$i]['type']))
{
- $sqls[] = $sql.' TYPE '.$field[$i]['type'].$field[$i]['length'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' TYPE '.$field[$i]['type'].$field[$i]['length'];
}
if ( ! empty($field[$i]['default']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
- .' SET '.$field[$i]['default'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' SET DEFAULT '.$field[$i]['default'];
}
if (isset($field[$i]['null']))
@@ -151,7 +152,7 @@ class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
if ( ! empty($field[$i]['new_name']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
}
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
index 866b6fb21..85d9445d3 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
@@ -171,7 +171,7 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
}
return $this->db->escape_identifiers($field['name'])
- .(empty($field['new_name']) ? '' : $this->db->escape_identifiers($field['new_name']))
+ .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
.$field['unsigned']
.$field['null']
diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
index 8052d218f..6d51a14b1 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
@@ -105,7 +105,7 @@ class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge {
$sql .= ' '.$alter_type.' ';
$sql .= (count($field) === 1)
- ? $fields[0]
+ ? $field[0]
: '('.implode(',', $field).')';
// RENAME COLUMN must be executed after MODIFY
diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
index 484c1603d..a24c898af 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php
@@ -103,7 +103,7 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
$sqls = array();
- for ($i = 0, $c = count($field), $sql .= $alter_type.' '; $i < $c; $i++)
+ for ($i = 0, $c = count($field); $i < $c; $i++)
{
if ($field[$i]['_literal'] !== FALSE)
{
@@ -112,24 +112,25 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type']))
{
- $sqls[] = $sql.' TYPE '.$field[$i]['type'].$field[$i]['length'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' TYPE '.$field[$i]['type'].$field[$i]['length'];
}
if ( ! empty($field[$i]['default']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
- .' SET '.$field[$i]['default'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' SET DEFAULT '.$field[$i]['default'];
}
if (isset($field[$i]['null']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
.($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL');
}
if ( ! empty($field[$i]['new_name']))
{
- $sqls[] = $sql.' RENAME '.$this->db->escape_identifiers($field[$i]['name'])
+ $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
}
}