Shooter7119 / sequel-pro

Automatically exported from code.google.com/p/sequel-pro
Other
0 stars 0 forks source link

Default value for ENUM type #1383

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Edit on GUI
2. Add an ENUM type
3. Uncheck "allow null"

What is the expected output? What do you see instead?
An error dialog jumped, because default value '' is not in ENUM. But I don't 
need a default value.

What version of Sequel Pro are you using? What version of MySQL are you
connecting to on the server?
0.9.9.1, 
5.5.9

Please provide any additional information below.

Original issue reported on code.google.com by xch...@bbtv.com on 25 Jun 2012 at 11:35

GoogleCodeExporter commented 9 years ago
Now this could easily be avoided if you just enter a default value by hand 
before clicking in the next row.

But yes, I think if Allow NULL is not selected and Default is empty for an ENUM 
field we should probably stick the first value of the ENUM there.

Original comment by schlabbe...@gmail.com on 26 Jun 2012 at 6:11

GoogleCodeExporter commented 9 years ago
Please adjust the priority of this issue. If this is required value, we 
shouldnt be auto populating an empty string.

For example this is perfectly valid

ALTER TABLE stock_history ADD record_type ENUM('delivery', 'stock_take') NOT 
NULL

which forces the insert query to specify a value. There should be no reason to 
require a default value. This makes it impossible to make such changes via the 
normal GUI, instead forcing me to make changes via manual ALTER statements.

Original comment by da...@temperedvision.com on 30 Jul 2012 at 9:42

GoogleCodeExporter commented 9 years ago
The example you show can be done by unchecking "Allow Null" and then entering 
"NULL" in the "Default" column.
This is a bit counter-intuitive but at least there is a way to accomplish this 
via GUI.

Original comment by schlabbe...@gmail.com on 30 Jul 2012 at 7:11

GoogleCodeExporter commented 9 years ago
If you don't want to allow nulls then the workaround mentioned is a no-go.

Original comment by jhalter...@gmail.com on 14 Dec 2012 at 9:20

GoogleCodeExporter commented 9 years ago
I've run into this issue too--I have a table with a field with type enum, Null 
is not allowed, and no default is set. I tried to edit the field to add an 
additional enum value, and it tried to set the default to '', rather than 
setting no default.
i.e., the query was:
ALTER TABLE `tablename` CHANGE `fieldname` `fieldname` ENUM('foo','bar','baz')  
CHARACTER SET utf8  COLLATE utf8_general_ci  NOT NULL  DEFAULT '';
Where I wanted: 
ALTER TABLE `tablename` CHANGE `fieldname` `fieldname` ENUM('foo','bar','baz')  
CHARACTER SET utf8  COLLATE utf8_general_ci  NOT NULL;

Original comment by danielk...@gmail.com on 6 Feb 2013 at 4:54

GoogleCodeExporter commented 9 years ago
Happy user, Just wanting to chime in that this issue recently bit me as well. I 
discovered the rather yucky workaround described three comments ago, but it 
took a while to figure out, and it feels like a real hassle.

My recommendation would involve having the GUI interpret "Allow Null" being 
unchecked and "Default" being blank such that a "DEFAULT" clause isn't included 
in the generated table-creation SQL at all.

Original comment by j...@appleseed-sc.com on 9 Nov 2013 at 12:40