Gossamer Forum
Home : Products : Others : MySQLMan :

entering a default value of 0 with not null for an int column

Quote Reply
entering a default value of 0 with not null for an int column
Having problem with int column since upgrading to mysql 5.0 when setting 'not null' and default 0 (zero) the column comes back not null but without a default....when entered as sql in SQL Monitor it works fine???

Any help appreciated.

Cheers
Quote Reply
Re: [chmodphil] entering a default value of 0 with not null for an int column In reply to
That looks like a bug. I'll look into a fix and getting you a patch on Monday.

Adrian
Quote Reply
Re: [brewt] entering a default value of 0 with not null for an int column In reply to
Thx Adrian, look forward to it...
Quote Reply
Re: [brewt] entering a default value of 0 with not null for an int column In reply to
Sorry it took so long - it's been a busy week. Here's a patch:
Code:
Index: MySQLMan.pm
===================================================================
RCS file: mysqlman/MySQLMan.pm,v
retrieving revision 1.28
diff -u -r1.28 MySQLMan.pm
--- MySQLMan.pm 10 Jun 2008 03:59:24 -0000 1.28
+++ MySQLMan.pm 25 Apr 2009 03:09:56 -0000
@@ -2942,8 +2942,9 @@
}
$col_spec .= ' ' . $IN->param("attributes_$i") . ' ';
$col_spec .= $IN->param("null_$i") . ' ';
- if ( $IN->param("default_$i") ) {
- $col_spec .= 'DEFAULT ' . $DBH->quote( $IN->param("default_$i") ) . ' ';
+ my $default = $IN->param("default_$i");
+ if (length $default) {
+ $col_spec .= 'DEFAULT ' . $DBH->quote($default) . ' ';
}
$col_spec .= $IN->param("extra_$i");

Adrian
Quote Reply
Re: [brewt] entering a default value of 0 with not null for an int column In reply to
Thanks for the fix Adrian it worked....
there is something else I noticed, unlike mysql 4 mysql 5 gives back 'NO' instead of '' for a column that is not null, this meant the selector in the alter form was defaulting to null even when the column was marked as not null so I mad a fix for it.

mysqlman/html.pl
sub html_alter_col

changed:
if ($null) { $null_select = '<option>null</option>' }
to:
if ($null eq 'YES') { $null_select = '<option>null</option>' }

Cheers