Doesn't MySQL silently set empty default (for string) or 0
(for numbers) if no default is set? Otherwise we would need
some checkbox whether to use default value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Why don't we force in the generated CREATE TABLE and ALTER
TABLE, a DEFAULT clause containing the appropriate value
(empty string or 0) depending on the field type, when there
is no default value coming from the GUI?
This should work, except for ENUM/SET where the default
value must be one of the list.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This was my suggestion that I made in a comment of bug
#1467709 (which I would contend is not really a duplicate
of this bug, since it had more to do with the error that
PMA receives when it incorrectly tries to interpret a
blank default value as an empty string, even for numeric
and date types):
The phpMyAdmin team might consider adding checkboxes next
to the default value fields in the edit table structure
page. If checked, the field would be editable, and the
corresponding column would be given the specified default
value. If not checked, the field would be cleared and
disabled, and the corresponding column would not be given
a default value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For TEXT and BLOB type columns, this is a non-issue
because they can't have default values anyway. For INT
and DATE type columns, this is a non-issue because they
can't have empty/blank default values, so an empty default
value can just be interpretted as NULL or no default
value, depending on the nullability of the column.
But, this is a big issue for CHAR/VARCHAR columns. In the
case of a CHAR NOT NULL column, does an empty default
value field mean that the default value should be the
empty string or should there be no default value at all?
In the case of a CHAR NULL column, does an empty default
value field mean that the default value should be the
empty string or should it be NULL? Likewise, does the
text "null" in the default value field mean the default
value should be the string "null" or should it be the NULL
value?
In short, there definitely needs to be a checkbox to
say "I want to give this column this default value."
Unchecked for NULL columns means default value is NULL.
Unchecked for NOT NULL columns means no default value is
defined.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Incidentally, (this should be obvious, but I'll say it
anyway), you don't have to say DEFAULT NULL in the SQL
query. You can just leave the DEFAULT clause out
entirely. So it's really easy to implement the checkbox.
If the box is checked, you have a DEFAULT clause in the
query. If it's not checked, you don't.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=192186
Doesn't MySQL silently set empty default (for string) or 0
(for numbers) if no default is set? Otherwise we would need
some checkbox whether to use default value.
Logged In: YES
user_id=326580
no, at least not in strict mode
and so MySQL 5 strict complaints about an insert with no
value for a field without a default value
Logged In: YES
user_id=192186
Okay, this is probably something for next release as we've
translation freeze right now and it would require new message.
Logged In: YES
user_id=326580
can we change the default input field that users have to use
'' to enclose strings?
making it possbile to enter empty strings: ''
making it possible to enter: CURRENT_TIMESTAMP, NULL,
CURRENT_TIMESTAMP() or NOW()
Logged In: YES
user_id=192186
IMHO forcing user to add quotes and escape string is not
good way.
I'd choose adding select for NULL/empty values.
Logged In: YES
user_id=210714
Why don't we force in the generated CREATE TABLE and ALTER
TABLE, a DEFAULT clause containing the appropriate value
(empty string or 0) depending on the field type, when there
is no default value coming from the GUI?
This should work, except for ENUM/SET where the default
value must be one of the list.
Logged In: YES
user_id=326580
any field type can have null as default,
for numeric fields this is not a problem empty means null
and any other value is casted to numeric value
but with text this is not so easy an empty value could mean
null or empty - how should PMA decide?
Logged In: YES
user_id=326580
closed duplicate:
https://sourceforge.net/tracker/index.php?func=detail&aid=1397978&group_id=23067&atid=377408
Logged In: YES
user_id=192186
Duplicate:
https://sourceforge.net/tracker/index.php?func=detail&aid=1467709&group_id=23067&atid=377408
Logged In: YES
user_id=1159156
This was my suggestion that I made in a comment of bug
#1467709 (which I would contend is not really a duplicate
of this bug, since it had more to do with the error that
PMA receives when it incorrectly tries to interpret a
blank default value as an empty string, even for numeric
and date types):
The phpMyAdmin team might consider adding checkboxes next
to the default value fields in the edit table structure
page. If checked, the field would be editable, and the
corresponding column would be given the specified default
value. If not checked, the field would be cleared and
disabled, and the corresponding column would not be given
a default value.
Logged In: YES
user_id=1159156
For TEXT and BLOB type columns, this is a non-issue
because they can't have default values anyway. For INT
and DATE type columns, this is a non-issue because they
can't have empty/blank default values, so an empty default
value can just be interpretted as NULL or no default
value, depending on the nullability of the column.
But, this is a big issue for CHAR/VARCHAR columns. In the
case of a CHAR NOT NULL column, does an empty default
value field mean that the default value should be the
empty string or should there be no default value at all?
In the case of a CHAR NULL column, does an empty default
value field mean that the default value should be the
empty string or should it be NULL? Likewise, does the
text "null" in the default value field mean the default
value should be the string "null" or should it be the NULL
value?
In short, there definitely needs to be a checkbox to
say "I want to give this column this default value."
Unchecked for NULL columns means default value is NULL.
Unchecked for NOT NULL columns means no default value is
defined.
Logged In: YES
user_id=1159156
Incidentally, (this should be obvious, but I'll say it
anyway), you don't have to say DEFAULT NULL in the SQL
query. You can just leave the DEFAULT clause out
entirely. So it's really easy to implement the checkbox.
If the box is checked, you have a DEFAULT clause in the
query. If it's not checked, you don't.
Logged In: YES
user_id=326580
Originator: YES
fixed in svn trunk, will be in 3.0
test here:
http://pma.cihar.com/trunk-config/