From 413643f1a032df121c10e24dbdfd38d81fe96cce Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 2 Apr 2015 10:10:26 +0000 Subject: [PATCH] Check whether column can be null, for composing a CREATE TABLE statement. Otherwise, leave away DEFAULT clause. See http://www.heidisql.com/forum.php?t=18055 --- source/dbconnection.pas | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 82f2eafc..3499931e 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -2661,9 +2661,11 @@ begin if Cols.Col('IS_NULLABLE') = 'NO' then Result := Result + ' NOT'; Result := Result + ' NULL'; - if Cols.IsNull('COLUMN_DEFAULT') then - Result := Result + ' DEFAULT NULL' - else begin + if Cols.IsNull('COLUMN_DEFAULT') then begin + // Check whether column can be null. Otherwise, leave away DEFAULT clause. + if Cols.Col('IS_NULLABLE') <> 'NO' then + Result := Result + ' DEFAULT NULL' + end else begin Result := Result + ' DEFAULT ' + Cols.Col('COLUMN_DEFAULT'); end; // The following is wrong syntax in PostgreSQL, but helps ParseTableStructure to find the comment