Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 34 additions and 21 deletions.
  1. +19 −21 classes/kohana/migration/column.php
  2. +15 −0 classes/kohana/migration/statement/changetable.php
View
40 classes/kohana/migration/column.php
@@ -37,18 +37,15 @@ class Kohana_Migration_Column {
'default_traits' => array()
),
'enum' => array(
- 'type' => 'ENUM',
- 'size' => null,
- 'null' => true,
- 'default' => null,
- 'comment' => null,
- 'traits' => array(
- 'unsigned' => 'UNSIGNED',
- 'auto_increment' => 'AUTO_INCREMENT',
- ),
- 'choices' => array(),
- 'default_traits' => array()
- ),
+ 'type' => 'ENUM',
+ 'size' => null,
+ 'null' => true,
+ 'default' => null,
+ 'comment' => null,
+ 'traits' => array(),
+ 'choices' => array(),
+ 'default_traits' => array()
+ ),
// TODO: http://www.ispirer.com/doc/sqlways39/Output/SQLWays-1-211.html
'text' => array(
'type' => 'TEXT',
@@ -150,8 +147,8 @@ public function __construct( $name, $type, $traits = null ) {
$this->comment = $trait;
break;
case 'choices':
- $this->choices[$key] = $trait;
- break;
+ $this->choices = $trait;
+ break;
default:
$this->traits[$key] = $trait;
break;
@@ -164,17 +161,18 @@ public function toSQL () {
$chunks = array(
"`{$this->name}`",
- vsprintf( self::$types[$this->type]['type'], $this->size )
+ sprintf( self::$types[$this->type]['type'], $this->size )
);
// ENUM
$chunks_choice = array();
- if( count($this->choices) > 0 ) {
- foreach($this->choices['choices'] as $key => $value) {
- $chunks_choice[] = "'".$value."'";
- }
- $chunks[] = '(' . implode( ',', $chunks_choice ) . ')';
- }
+
+ if( count($this->choices) > 0 ) {
+ foreach( $this->choices as $value ) {
+ $chunks_choice[] = "'".addslashes($value)."'";
+ }
+ $chunks[] = '(' . implode( ',', $chunks_choice ) . ')';
+ }
$requested_traits = array_merge( self::$types[$this->type]['default_traits'], $this->traits );
foreach( $requested_traits as $key => $trait ) {
View
15 classes/kohana/migration/statement/changetable.php
@@ -2,10 +2,25 @@
class Kohana_Migration_Statement_ChangeTable extends Kohana_Migration_Statement {
+ /**
+ * @var string
+ */
protected $_tableName;
+ /**
+ * @var string
+ */
protected $_engine;
+ /**
+ * @var string
+ */
protected $_charset;
+ /**
+ * @var Kohana_Migration_Column[]
+ */
protected $_addColumns = array();
+ /**
+ * @var string[]
+ */
protected $_removeColumns = array();
// Change == Rename
protected $_changeColumns = array();

No commit comments for this range

Something went wrong with that request. Please try again.