From 1660104d4d0889bd9fd9b347744eb78aa2c3d634 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 1 Jul 2013 04:23:06 +0000 Subject: [PATCH] Support length of "max" in data types. Used in MSSQL. --- source/dbconnection.pas | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 67e9c61f..c6593950 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -1831,7 +1831,7 @@ end; function TAdoDBConnection.GetCreateCode(Database, Schema, Name: String; NodeType: TListNodeType): String; var Cols, Keys: TDBQuery; - ConstraintName: String; + ConstraintName, MaxLen: String; ColNames: TStringList; // Return fitting schema clause for queries in IS.TABLES, IS.ROUTINES etc. @@ -1857,8 +1857,13 @@ begin ); while not Cols.Eof do begin Result := Result + CRLF + #9 + QuoteIdent(Cols.Col('COLUMN_NAME')) + ' ' + UpperCase(Cols.Col('DATA_TYPE')); - if not Cols.IsNull('CHARACTER_MAXIMUM_LENGTH') then - Result := Result + '(' + Cols.Col('CHARACTER_MAXIMUM_LENGTH') + ')'; + if not Cols.IsNull('CHARACTER_MAXIMUM_LENGTH') then begin + MaxLen := Cols.Col('CHARACTER_MAXIMUM_LENGTH'); + if MaxLen = '-1' then + Result := Result + '(max)' + else + Result := Result + '(' + MaxLen + ')'; + end; if Cols.Col('IS_NULLABLE') = 'NO' then Result := Result + ' NOT'; Result := Result + ' NULL';