Skip to content
Permalink
Browse files

Issue #12: remove "database." part from reference table in foreign ke…

…y code, as this throws an error: near ".": syntax error. Makes "Create table copy" dialog compatible to SQLite, except for indexes yet
  • Loading branch information
ansgarbecker committed Jan 19, 2020
1 parent e770dcb commit d5e5a8292d745eb1439d9a1b0a4fd26e7b67af4b
Showing with 7 additions and 6 deletions.
  1. +6 −5 source/copytable.pas
  2. +1 −1 source/dbconnection.pas
@@ -376,11 +376,12 @@ procedure TCopyTableForm.btnOKClick(Sender: TObject);
TargetTable := FConnection.QuotedDbAndTableName(comboDatabase.Text, editNewTablename.Text);

// Watch out if target table exists
TableExistence := FConnection.GetVar('SELECT '+FConnection.QuoteIdent('table_name')+
' FROM '+FConnection.QuoteIdent(FConnection.InfSch)+'.'+FConnection.QuoteIdent('tables')+
' WHERE '+FConnection.QuoteIdent(FConnection.GetSQLSpecifity(spISTableSchemaCol))+'='+FConnection.EscapeString(comboDatabase.Text)+
' AND '+FConnection.QuoteIdent('table_name')+'='+FConnection.EscapeString(editNewTablename.Text)
);
try
TableExistence := FConnection.GetVar('SELECT 1 FROM '+
FConnection.QuoteIdent(comboDatabase.Text)+'.'+FConnection.QuoteIdent(editNewTablename.Text));
except
TableExistence := '';
end;
if TableExistence <> '' then begin
if MessageDialog(_('Target table exists. Drop it and overwrite?'), mtConfirmation, [mbYes, mbCancel]) = mrCancel then begin
ModalResult := mrNone;
@@ -4992,7 +4992,7 @@ function TSQLiteConnection.GetTableForeignKeys(Table: TDBObject): TForeignKeyLis
Result.Add(ForeignKey);
ForeignKey.KeyName := ForeignQuery.Col('id');
ForeignKey.OldKeyName := ForeignKey.KeyName;
ForeignKey.ReferenceTable := Table.Database + '.' + ForeignQuery.Col('table');
ForeignKey.ReferenceTable := ForeignQuery.Col('table');
ForeignKey.OnUpdate := ForeignQuery.Col('on_update');
ForeignKey.OnDelete := ForeignQuery.Col('on_delete');
end;

0 comments on commit d5e5a82

Please sign in to comment.
You can’t perform that action at this time.