mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Fix invalid SQL code for dropping foreign key constraint in PostgreSQL mode. Closes #1247
This commit is contained in:
@@ -428,7 +428,8 @@ type
|
||||
spUSEQuery, spKillQuery, spKillProcess,
|
||||
spFuncLength, spFuncCeil, spFuncLeft, spFuncNow, spFuncLastAutoIncNumber,
|
||||
spLockedTables, spDisableForeignKeyChecks, spEnableForeignKeyChecks,
|
||||
spOrderAsc, spOrderDesc);
|
||||
spOrderAsc, spOrderDesc,
|
||||
spForeignKeyDrop);
|
||||
|
||||
TDBConnection = class(TComponent)
|
||||
private
|
||||
@@ -3081,6 +3082,7 @@ begin
|
||||
FSQLSpecifities[spLockedTables] := '';
|
||||
FSQLSpecifities[spDisableForeignKeyChecks] := 'SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0';
|
||||
FSQLSpecifities[spEnableForeignKeyChecks] := 'SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1)';
|
||||
FSQLSpecifities[spForeignKeyDrop] := 'DROP FOREIGN KEY %s';
|
||||
end;
|
||||
ngMSSQL: begin
|
||||
FSQLSpecifities[spDatabaseDrop] := 'DROP DATABASE %s';
|
||||
@@ -3105,6 +3107,7 @@ begin
|
||||
FSQLSpecifities[spLockedTables] := '';
|
||||
FSQLSpecifities[spDisableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spEnableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spForeignKeyDrop] := 'DROP FOREIGN KEY %s';
|
||||
end;
|
||||
ngPgSQL: begin
|
||||
FSQLSpecifities[spDatabaseDrop] := 'DROP SCHEMA %s';
|
||||
@@ -3131,6 +3134,7 @@ begin
|
||||
FSQLSpecifities[spLockedTables] := '';
|
||||
FSQLSpecifities[spDisableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spEnableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spForeignKeyDrop] := 'DROP CONSTRAINT %s';
|
||||
end;
|
||||
ngSQLite: begin
|
||||
FSQLSpecifities[spDatabaseDrop] := 'DROP DATABASE %s';
|
||||
@@ -3156,6 +3160,7 @@ begin
|
||||
FSQLSpecifities[spLockedTables] := '';
|
||||
FSQLSpecifities[spDisableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spEnableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spForeignKeyDrop] := 'DROP FOREIGN KEY %s';
|
||||
end;
|
||||
ngInterbase: begin
|
||||
FSQLSpecifities[spDatabaseDrop] := 'DROP DATABASE %s';
|
||||
@@ -3184,6 +3189,7 @@ begin
|
||||
FSQLSpecifities[spLockedTables] := '';
|
||||
FSQLSpecifities[spDisableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spEnableForeignKeyChecks] := '';
|
||||
FSQLSpecifities[spForeignKeyDrop] := 'DROP FOREIGN KEY %s';
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
@@ -600,7 +600,7 @@ begin
|
||||
// ALTER TABLE statement. Separate statements are required."
|
||||
for i:=0 to FForeignKeys.Count-1 do begin
|
||||
if FForeignKeys[i].Modified and (not FForeignKeys[i].Added) then
|
||||
Specs.Add('DROP FOREIGN KEY '+Conn.QuoteIdent(FForeignKeys[i].OldKeyName));
|
||||
Specs.Add(DBObject.Connection.GetSQLSpecifity(spForeignKeyDrop, [Conn.QuoteIdent(FForeignKeys[i].OldKeyName)]));
|
||||
end;
|
||||
FinishSpecs;
|
||||
|
||||
@@ -805,8 +805,9 @@ begin
|
||||
Specs.Add('ADD '+FKeys[i].SQLCode);
|
||||
end;
|
||||
|
||||
for i:=0 to FDeletedForeignKeys.Count-1 do
|
||||
Specs.Add('DROP FOREIGN KEY '+Conn.QuoteIdent(FDeletedForeignKeys[i]));
|
||||
for i:=0 to FDeletedForeignKeys.Count-1 do begin
|
||||
Specs.Add(DBObject.Connection.GetSQLSpecifity(spForeignKeyDrop, [Conn.QuoteIdent(FDeletedForeignKeys[i])]));
|
||||
end;
|
||||
for i:=0 to FForeignKeys.Count-1 do begin
|
||||
if FForeignKeys[i].Added or FForeignKeys[i].Modified then
|
||||
Specs.Add('ADD '+FForeignKeys[i].SQLCode(True));
|
||||
|
||||
Reference in New Issue
Block a user