diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 0713ab18..0301eb2f 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -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; diff --git a/source/table_editor.pas b/source/table_editor.pas index 70ef6b60..1786f3c0 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -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));