vieten / sequel-pro

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

[REQ] Add visual indicator for fields that default to NULL #1211

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
One major problem I met today was trying to trigger an error in the database by 
setting a NOT NULL field to NULL. Somehow, it always managed to come up with an 
empty field anyway. It turns out this was because the default was set to '', an 
empty string, which meant that any NULLs were just turned into empty strings. 
It's completely impossible to distinguish a NULL default to an empty string 
default.

This is especially important for systems that rely on ORM frameworks - these 
frameworks generally examine if a field has NOT NULL and no default set, and if 
so, will flag a field as "not required" - but with a default, including an 
empty string one, this functionality fails, and users can insert blank fields 
into the database. Generally a bad thing.

Since one can simply type "NULL" in Sequel's default field, this is easy to 
fix, but it's impossible to tell which fields are affected, other than going 
into Table Info > Create Syntax. A simple visual indicator - maybe a grayed-out 
"NULL" label, or highlighting the cell yellow - would really help people in 
this situation.

Original issue reported on code.google.com by RizqiDja...@gmail.com on 11 Oct 2011 at 6:31

GoogleCodeExporter commented 9 years ago
Minor typo - ORMs will search for fields that have NOT NULL and no default, and 
will flag those fields as "required".

Original comment by RizqiDja...@gmail.com on 11 Oct 2011 at 6:33

GoogleCodeExporter commented 9 years ago
If I understand you the problem is that an >empty string< and >nothing< as 
default value look the same?

Original comment by schlabbe...@gmail.com on 11 Oct 2011 at 7:03

GoogleCodeExporter commented 9 years ago
Yes - there is no visual difference between NULL and "" (an empty string).

It's quite important because having a field set to NOT NULL and having a 
default value of NULL (basically, no default) is very different than it having 
a default value of "". The first one does not allow NULL inputs, while second 
does.

Original comment by RizqiDja...@gmail.com on 12 Oct 2011 at 2:19

GoogleCodeExporter commented 9 years ago
NULL as default is actually shown as NULL by SP.
Only "no default" and "empty string" will look like an empty field.

Original comment by schlabbe...@gmail.com on 14 Oct 2011 at 8:14

GoogleCodeExporter commented 9 years ago

Original comment by stuart02 on 25 Oct 2011 at 7:22