Skip to content

Commit

Permalink
FB:fix add not null collumn to exist table
Browse files Browse the repository at this point in the history
  • Loading branch information
lalexs75 committed Dec 20, 2023
1 parent 5bc0458 commit 9decd65
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion IBManager.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<AutoIncrementBuild Value="True"/>
<MinorVersionNr Value="13"/>
<RevisionNr Value="3"/>
<BuildNr Value="5730"/>
<BuildNr Value="5731"/>
<Language Value="0419"/>
<Attributes pvaPreRelease="True"/>
<StringTable FileDescription="Tools for manage you databases" LegalCopyright="Lagunov A.A." ProductVersion="0.13"/>
Expand Down
Binary file modified IBManager.res
Binary file not shown.
21 changes: 14 additions & 7 deletions sql_engine/firebird/fb_sqlparserunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7216,19 +7216,19 @@ function TFBSQLCreateTable.GetAutoIncObject: TAutoIncObject;

procedure TFBSQLAlterTable.AddCollumn(OP: TAlterTableOperator);
var
S, S_CONSTR: String;
S, S_CONSTR, S1: String;
C: TSQLConstraintItem;
begin
S:='';

S1:='';
if OP.Field.CharSetName <> '' then
S:=S + ' CHARACTER SET ' + OP.Field.CharSetName;

if OP.Field.Collate <> '' then
S:=S + ' COLLATE ' + OP.Field.Collate;

if fpNotNull in OP.Field.Params then
S:=S + ' NOT NULL';
S1:=S1 + ' NOT NULL';


S_CONSTR:='';
Expand Down Expand Up @@ -7269,15 +7269,22 @@ procedure TFBSQLAlterTable.AddCollumn(OP: TAlterTableOperator);
end;
end;

if S_CONSTR <> '' then S:=S + ' ' + S_CONSTR;
if S_CONSTR <> '' then S1:=S1 + ' ' + S_CONSTR;

AddSQLCommandEx('ALTER TABLE %s ADD %s %s', [Name, OP.Field.Caption, OP.Field.FullTypeName + S]);
if OP.InitialValue <> '' then
begin
AddSQLCommandEx('ALTER TABLE %s ADD %s %s', [FullName, DoFormatName(OP.Field.Caption), OP.DBMSTypeName]);
AddSQLCommandEx('UPDATE %s SET %s = %s', [Name, OP.Field.Caption, OP.InitialValue]);
AddSQLCommandEx('ALTER TABLE %s ALTER COLUMN %s TYPE %s', [FullName, DoFormatName(OP.Field.Caption), OP.Field.FullTypeName + S]);
if S1<>'' then
AddSQLCommandEx('ALTER TABLE %s ALTER %s SET %s', [FullName, DoFormatName(OP.Field.Caption), S1]);
end
else
AddSQLCommandEx('ALTER TABLE %s ADD %s %s', [Name, OP.Field.Caption, OP.Field.FullTypeName + S]);

if OP.Field.DefaultValue <> '' then
AddSQLCommandEx('ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s', [Name, OP.Field.Caption, OP.Field.DefaultValue]);

if OP.InitialValue <> '' then
AddSQLCommandEx('UPDATE %s SET %s = %s', [Name, OP.Field.Caption, OP.InitialValue]);

if OP.Field.Description<>'' then
DescribeObjectEx(okColumn, OP.Field.Caption, Name, OP.Field.Description);
Expand Down

0 comments on commit 9decd65

Please sign in to comment.