Skip to content

Commit

Permalink
fix(SchemaBuilder): Wrap enum values in single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Nov 28, 2018
1 parent 7273ce4 commit 89b58c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion models/Grammars/BaseGrammar.cfc
Expand Up @@ -1137,7 +1137,7 @@ component displayname="Grammar" accessors="true" {

function typeEnum( column ) {
var values = column.getValues().map( function ( value ) {
return wrapValue( value );
return "'#value#'";
} ).toList( ", " );
return "ENUM(#values#)";
}
Expand Down
8 changes: 4 additions & 4 deletions tests/specs/Schema/MySQLSchemaBuilderSpec.cfc
Expand Up @@ -70,7 +70,7 @@ component extends="tests.resources.AbstractSchemaBuilderSpec" {

function enum() {
return [
"CREATE TABLE `employees` (`tshirt_size` ENUM(`S`, `M`, `L`, `XL`, `XXL`) NOT NULL)"
"CREATE TABLE `employees` (`tshirt_size` ENUM('S', 'M', 'L', 'XL', 'XXL') NOT NULL)"
];
}

Expand Down Expand Up @@ -371,21 +371,21 @@ component extends="tests.resources.AbstractSchemaBuilderSpec" {

function addColumn() {
return [
"ALTER TABLE `users` ADD `tshirt_size` ENUM(`S`, `M`, `L`, `XL`, `XXL`) NOT NULL"
"ALTER TABLE `users` ADD `tshirt_size` ENUM('S', 'M', 'L', 'XL', 'XXL') NOT NULL"
];
}

function addMultiple() {
return [
"ALTER TABLE `users` ADD `tshirt_size` ENUM(`S`, `M`, `L`, `XL`, `XXL`) NOT NULL",
"ALTER TABLE `users` ADD `tshirt_size` ENUM('S', 'M', 'L', 'XL', 'XXL') NOT NULL",
"ALTER TABLE `users` ADD `is_active` TINYINT(1) NOT NULL"
];
}

function complicatedModify() {
return [
"ALTER TABLE `users` DROP COLUMN `is_active`",
"ALTER TABLE `users` ADD `tshirt_size` ENUM(`S`, `M`, `L`, `XL`, `XXL`) NOT NULL",
"ALTER TABLE `users` ADD `tshirt_size` ENUM('S', 'M', 'L', 'XL', 'XXL') NOT NULL",
"ALTER TABLE `users` CHANGE `name` `username` NVARCHAR(255) NOT NULL",
"ALTER TABLE `users` CHANGE `purchase_date` `purchase_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP",
"ALTER TABLE `users` ADD CONSTRAINT `unq_users_username` UNIQUE (`username`)",
Expand Down

0 comments on commit 89b58c4

Please sign in to comment.