Skip to content

Commit

Permalink
Issue #12: Implement TDBConnection.GetTableColumns and .GetTableKeys …
Browse files Browse the repository at this point in the history
…(todo: .GetTableForeignKeys), as a replacement for the error prone ParseTableStructure. SQLite columns and keys should be parsed correctly now, MS SQL and PostgreSQL may now have some glitches to fix.
  • Loading branch information
ansgarbecker committed Jan 8, 2020
1 parent 0d0c6df commit b45a0d5
Show file tree
Hide file tree
Showing 7 changed files with 430 additions and 114 deletions.
17 changes: 9 additions & 8 deletions source/copytable.pas
Expand Up @@ -72,9 +72,6 @@ procedure TCopyTableForm.FormCreate(Sender: TObject);
Height := AppSettings.ReadInt(asCopyTableWindowHeight);
MainForm.SetupSynEditors;
FixVT(TreeElements);
FColumns := TTableColumnList.Create;
FKeys := TTableKeyList.Create;
FForeignKeys := TForeignKeyList.Create;
end;


Expand Down Expand Up @@ -129,12 +126,16 @@ procedure TCopyTableForm.FormShow(Sender: TObject);
comboDatabase.ItemIndex := 0;

// Fetch columns and key structures from table or view
FColumns.Clear;
FKeys.Clear;
FForeignKeys.Clear;
case FDBObj.NodeType of
lntTable: FConnection.ParseTableStructure(FDBObj.CreateCode, FColumns, FKeys, FForeignKeys);
lntView: FConnection.ParseViewStructure(FDBObj.CreateCode, FDBObj, FColumns, Dummy, Dummy, Dummy, Dummy, Dummy);
lntTable: begin
FColumns := FDBObj.TableColumns;
FKeys := FDBObj.TableKeys;
FForeignKeys := FDBObj.TableForeignKeys;
end;
lntView: begin
FColumns := TTableColumnList.Create;
FConnection.ParseViewStructure(FDBObj.CreateCode, FDBObj, FColumns, Dummy, Dummy, Dummy, Dummy, Dummy);
end
else raise Exception.CreateFmt(_('Neither table nor view: %s'), [FDBObj.Name]);
end;

Expand Down

0 comments on commit b45a0d5

Please sign in to comment.