Terminology update: a table consists of columns vs rows, and the intersection of a row and a column is called a field.

(Except for Delphi's TField and MySql's FIELD, obviously, which are harder to fix.)
This commit is contained in:
rosenfield.albert
2008-08-07 18:56:06 +00:00
parent 614a6a813c
commit bfbf1ee2f1
8 changed files with 108 additions and 108 deletions

View File

@ -285,7 +285,7 @@ type
procedure pcChange(Sender: TObject);
procedure ValidateControls(FrmIsFocussed: Boolean = true);
procedure ValidateQueryControls(FrmIsFocussed: Boolean = true);
function FieldContent(ds: TDataSet; FieldName: String): String;
function FieldContent(ds: TDataSet; ColName: String): String;
procedure LoadDatabaseProperties(db: string);
procedure ShowHost;
procedure ShowDatabase(db: String);
@ -1159,7 +1159,7 @@ var
DisplayedColumnsList,
HiddenKeyCols,
KeyCols : WideStrings.TWideStringList;
Filter, FieldName : WideString;
Filter, ColName : WideString;
col : TVirtualTreeColumn;
rx : TRegExpr;
ds : TDataSet;
@ -1235,7 +1235,7 @@ begin
end;
// Cut last comma
select_base := copy( select_base, 1, Length(select_base)-1 );
// Signal for the user that we now hide some fields
// Signal for the user that we now hide some columns
tbtnDataColumns.ImageIndex := 108;
end;
select_base := select_base + ' FROM ' + mask( SelectedTable );
@ -1266,11 +1266,11 @@ begin
MainForm.ShowStatus('Filling grid with record-data...');
SetLength(FDataGridResult.Columns, ds.FieldCount);
for i:=0 to ds.FieldCount-1 do begin
FieldName := ds.Fields[i].FieldName;
FDataGridResult.Columns[i].Name := FieldName;
ColName := ds.Fields[i].FieldName;
FDataGridResult.Columns[i].Name := ColName;
col := DataGrid.Header.Columns.Add;
col.Text := FieldName;
if HiddenKeyCols.IndexOf(FieldName) > -1 then
col.Text := ColName;
if HiddenKeyCols.IndexOf(ColName) > -1 then
col.Options := col.Options - [coVisible];
col.Width := prefDefaultColWidth;
// Sorting color and title image
@ -1285,7 +1285,7 @@ begin
// Right alignment for numeric columns
FSelectedTableColumns.First;
while not FSelectedTableColumns.Eof do begin
if FSelectedTableColumns.FieldByName('Field').AsWideString = FieldName then begin
if FSelectedTableColumns.FieldByName('Field').AsWideString = ColName then begin
rx := TRegExpr.Create;
rx.Expression := '^(tiny|small|medium|big)?int\b';
if rx.Exec(FSelectedTableColumns.FieldByName('Type').AsWideString) then begin
@ -1313,7 +1313,7 @@ begin
FSelectedTableKeys.First;
for j := 0 to FSelectedTableKeys.RecordCount - 1 do begin
if (FSelectedTableKeys.FieldByName('Key_name').AsString = 'PRIMARY')
and (FSelectedTableKeys.FieldByName('Column_name').AsWideString = FieldName) then begin
and (FSelectedTableKeys.FieldByName('Column_name').AsWideString = ColName) then begin
FDataGridResult.Columns[i].IsPK := True;
break;
end;
@ -1374,7 +1374,7 @@ begin
if GetSelectedNodeType = NODETYPE_TABLE then begin
// Get rowcount from table
rows_total := StrToInt64( GetVar( 'SELECT COUNT(*) FROM ' + mask( SelectedTable ), 0 ) );
lblDataTop.Caption := lblDataTop.Caption + FormatNumber( rows_total ) + ' records total';
lblDataTop.Caption := lblDataTop.Caption + FormatNumber( rows_total ) + ' rows total';
end else begin
// Don't fetch rowcount from views to fix bug #1844952
rows_total := -1;
@ -1414,7 +1414,7 @@ begin
if ( rows_matching = rows_total ) and
(Filter <> '') then
lblDataTop.Caption := lblDataTop.Caption + ', filter matches all records';
lblDataTop.Caption := lblDataTop.Caption + ', filter matches all rows';
if ( mainform.CheckBoxLimit.Checked ) and
( rows_matching > StrToIntDef( mainform.EditLimitEnd.Text, 0 ) ) then
@ -1571,14 +1571,14 @@ end;
// Fetch content from a row cell, avoiding NULLs to cause AVs
function TMDIChild.FieldContent(ds: TDataSet; FieldName: String): String;
function TMDIChild.FieldContent(ds: TDataSet; ColName: String): String;
begin
Result := '';
if
(ds.FindField(FieldName) <> nil) and
(not ds.FindField(FieldName).IsNull)
(ds.FindField(colName) <> nil) and
(not ds.FindField(ColName).IsNull)
then
Result := ds.FieldByName(FieldName).AsString;
Result := ds.FieldByName(ColName).AsString;
end;
@ -1616,7 +1616,7 @@ begin
begin
VTRowDataListTables[i-1].ImageIndex := ICONINDEX_TABLE;
VTRowDataListTables[i-1].NodeType := NODETYPE_TABLE;
// Records
// Rows
if ds.FindField('Rows') <> nil then
ListCaptions.Add( FormatNumber( FieldContent(ds, 'Rows') ) )
else
@ -1888,7 +1888,7 @@ begin
pcChange( Self );
MainForm.ShowStatus( STATUS_MSG_READY );
MainForm.showstatus(ActiveDatabase + ': '+ table + ': ' + IntToStr(ListColumns.RootNodeCount) +' field(s)', 0);
MainForm.showstatus(ActiveDatabase + ': '+ table + ': ' + IntToStr(ListColumns.RootNodeCount) +' column(s)', 0);
Screen.Cursor := crDefault;
end;
@ -2318,7 +2318,7 @@ var
fieldcount : Integer;
recordcount : Integer;
ds : TDataSet;
FieldName : WideString;
ColName : WideString;
col : TVirtualTreeColumn;
begin
if CurrentLine then SQL := parseSQL(SynMemoQuery.LineText)
@ -2402,8 +2402,8 @@ begin
LabelResultinfo.Caption :=
FormatNumber( rowsaffected ) +' row(s) affected, '+
FormatNumber( fieldcount ) +' field(s) / '+
FormatNumber( recordcount ) +' record(s) in last result set.';
FormatNumber( fieldcount ) +' column(s) / '+
FormatNumber( recordcount ) +' row(s) in last result set.';
if ( SQL.Count = 1 ) then
begin
LabelResultinfo.Caption := LabelResultinfo.Caption +
@ -2436,12 +2436,12 @@ begin
SetLength(FQueryGridResult.Columns, 0);
SetLength(FQueryGridResult.Columns, ds.FieldCount);
for i:=0 to ds.FieldCount-1 do begin
FieldName := ds.Fields[i].FieldName;
ColName := ds.Fields[i].FieldName;
col := QueryGrid.Header.Columns.Add;
col.Text := FieldName;
col.Text := ColName;
col.Width := prefDefaultColWidth;
col.Options := col.Options - [coAllowClick];
FQueryGridResult.Columns[i].Name := FieldName;
FQueryGridResult.Columns[i].Name := ColName;
if ds.Fields[i].DataType in [ftSmallint, ftInteger, ftWord, ftLargeint] then begin
FQueryGridResult.Columns[i].IsInt := True;
col.Alignment := taRightJustify;

View File

@ -78,7 +78,7 @@ object CopyTableForm: TCopyTableForm
Top = 141
Width = 97
Height = 17
Caption = 'With all Fields'
Caption = 'With all Columns'
Checked = True
State = cbChecked
TabOrder = 1

View File

@ -382,7 +382,7 @@ object CreateTableForm: TCreateTableForm
Width = 153
Height = 21
Style = csDropDownList
ItemHeight = 13
ItemHeight = 0
TabOrder = 1
end
object ComboBoxTableType: TComboBox
@ -391,7 +391,7 @@ object CreateTableForm: TCreateTableForm
Width = 153
Height = 21
Style = csDropDownList
ItemHeight = 13
ItemHeight = 0
TabOrder = 3
end
object comboCharset: TComboBox
@ -400,7 +400,7 @@ object CreateTableForm: TCreateTableForm
Width = 153
Height = 21
Style = csDropDownList
ItemHeight = 13
ItemHeight = 0
Sorted = True
TabOrder = 10
OnChange = comboCharsetChange
@ -411,7 +411,7 @@ object CreateTableForm: TCreateTableForm
Width = 153
Height = 21
Style = csDropDownList
ItemHeight = 13
ItemHeight = 0
Sorted = True
TabOrder = 12
end

View File

@ -70,7 +70,7 @@ type
procedure EditFieldnameChange(Sender: TObject);
procedure ListboxColumnsClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure refreshfields(Sender: TObject);
procedure refreshColumnList(Sender: TObject);
procedure ButtonChangeClick(Sender: TObject);
procedure ComboBoxTypeChange(Sender: TObject);
procedure EditLengthSetChange(Sender: TObject);
@ -99,7 +99,7 @@ uses
Main, Childwin, helpers, mysql_structures;
var
fields : array of TMysqlField;
cols : array of TMysqlField;
{$R *.DFM}
@ -161,12 +161,12 @@ begin
createQuery := 'CREATE TABLE ' + mainform.mask(DBComboBox.Text) + '.' + mainform.mask(EditTablename.Text) + ' (';
// Columns
for i := 0 to length(fields) - 1 do
for i := 0 to length(cols) - 1 do
begin
FieldType := MySqlDataTypeArray[fields[i].FieldType];
createQuery := createQuery + mainform.mask(fields[i].Name) + ' ' +
comboboxtype.items[fields[i].FieldType]; // Typ
LengthSet := fields[i].LengthSet;
FieldType := MySqlDataTypeArray[cols[i].FieldType];
createQuery := createQuery + mainform.mask(cols[i].Name) + ' ' +
comboboxtype.items[cols[i].FieldType]; // Typ
LengthSet := cols[i].LengthSet;
// Unset length if not allowed for fieldtype
if not FieldType.HasLength then
LengthSet := '';
@ -180,20 +180,20 @@ begin
end;
if LengthSet <> '' then
createQuery := createQuery + ' (' + LengthSet + ')'; // Length/Set
if FieldType.HasBinary and fields[i].Binary then
if FieldType.HasBinary and cols[i].Binary then
createQuery := createQuery + ' BINARY'; // Binary
if FieldType.HasUnsigned and fields[i].Unsigned then
if FieldType.HasUnsigned and cols[i].Unsigned then
createQuery := createQuery + ' UNSIGNED'; // Unsigned
if FieldType.HasZerofill and fields[i].Zerofill then
if FieldType.HasZerofill and cols[i].Zerofill then
createQuery := createQuery + ' ZEROFILL'; // Zerofill
if fields[i].Default <> '' then
createQuery := createQuery + ' DEFAULT ''' + fields[i].Default + ''''; // Default
if fields[i].NotNull then
if cols[i].Default <> '' then
createQuery := createQuery + ' DEFAULT ''' + cols[i].Default + ''''; // Default
if cols[i].NotNull then
createQuery := createQuery + ' NOT NULL'; // Not null
if fields[i].AutoIncrement then
if cols[i].AutoIncrement then
createQuery := createQuery + ' AUTO_INCREMENT'; // AutoIncrement
if i < length(fields)-1 then
if i < length(cols)-1 then
createQuery := createQuery + ', '
end;
@ -201,22 +201,22 @@ begin
primaryKey := '';
uniqueKey := '';
indexKey := '';
for i := 0 to length(fields) - 1 do
for i := 0 to length(cols) - 1 do
begin
if fields[i].Primary then
if cols[i].Primary then
begin
if primaryKey <> '' then primaryKey := primaryKey + ',';
primaryKey := primaryKey + mainform.mask(fields[i].Name);
primaryKey := primaryKey + mainform.mask(cols[i].Name);
end;
if fields[i].Unique then
if cols[i].Unique then
begin
if uniqueKey <> '' then uniqueKey := uniqueKey + ',';
uniqueKey := uniqueKey + mainform.mask(fields[i].Name);
uniqueKey := uniqueKey + mainform.mask(cols[i].Name);
end;
if fields[i].Index then
if cols[i].Index then
begin
if indexKey <> '' then indexKey := indexKey + ',';
indexKey := indexKey + mainform.mask(fields[i].Name);
indexKey := indexKey + mainform.mask(cols[i].Name);
end;
end;
if primaryKey <> '' then
@ -258,16 +258,16 @@ end;
procedure TCreateTableForm.refreshfields(Sender: TObject);
procedure TCreateTableForm.refreshColumnList(Sender: TObject);
var i : word;
begin
// refresh field-list
// refresh list of columns
with ListboxColumns do
begin
Items.Clear;
if length(fields) > 0 then
for i := 0 to length(fields)-1 do
Items.Add(fields[i].Name);
if length(cols) > 0 then
for i := 0 to length(cols)-1 do
Items.Add(cols[i].Name);
ItemIndex := index;
end;
if index = -1 then
@ -293,18 +293,18 @@ end;
procedure TCreateTableForm.ButtonDeleteClick(Sender: TObject);
var i : Word;
begin
// delete field
if length(fields) > 1 then
for i := index to length(fields)-2 do
// remove column
if length(cols) > 1 then
for i := index to length(cols)-2 do
begin
fields[i] := fields[i+1];
cols[i] := cols[i+1];
end;
setlength(fields, length(fields)-1);
setlength(cols, length(cols)-1);
dec(index);
refreshfields(self);
refreshColumnList(self);
EditFieldNameChange(self);
ListboxColumnsClick(self);
if length(fields) = 0 then
if length(cols) = 0 then
begin
ButtonMoveUp.Enabled := false;
ButtonMoveDown.Enabled := false;
@ -362,14 +362,14 @@ end;
procedure TCreateTableForm.ComboBoxTypeChange(Sender: TObject);
begin
// Type
fields[index].FieldType := ComboBoxType.ItemIndex;
cols[index].FieldType := ComboBoxType.ItemIndex;
checktypes(self);
end;
procedure TCreateTableForm.EditLengthSetChange(Sender: TObject);
begin
// LengthSet
fields[index].LengthSet := EditLengthSet.Text;
cols[index].LengthSet := EditLengthSet.Text;
end;
@ -399,63 +399,63 @@ end;
procedure TCreateTableForm.EditDefaultChange(Sender: TObject);
begin
// Default
fields[index].Default := EditDefault.Text;
cols[index].Default := EditDefault.Text;
end;
procedure TCreateTableForm.CheckBoxPrimaryClick(Sender: TObject);
begin
// Primary
fields[index].Primary := CheckBoxPrimary.Checked;
cols[index].Primary := CheckBoxPrimary.Checked;
end;
procedure TCreateTableForm.CheckBoxIndexClick(Sender: TObject);
begin
// Index
fields[index].Index := CheckBoxIndex.Checked;
cols[index].Index := CheckBoxIndex.Checked;
end;
procedure TCreateTableForm.CheckBoxUniqueClick(Sender: TObject);
begin
// Unique
fields[index].Unique := CheckBoxUnique.Checked;
cols[index].Unique := CheckBoxUnique.Checked;
end;
procedure TCreateTableForm.CheckBoxBinaryClick(Sender: TObject);
begin
// Binary
fields[index].Binary := CheckBoxBinary.Checked;
cols[index].Binary := CheckBoxBinary.Checked;
end;
procedure TCreateTableForm.CheckBoxUnsignedClick(Sender: TObject);
begin
// Unsigned
fields[index].Unsigned := CheckBoxUnsigned.Checked;
cols[index].Unsigned := CheckBoxUnsigned.Checked;
end;
procedure TCreateTableForm.CheckBoxZerofillClick(Sender: TObject);
begin
// Zerofill
fields[index].Zerofill := CheckBoxZerofill.Checked;
cols[index].Zerofill := CheckBoxZerofill.Checked;
end;
procedure TCreateTableForm.CheckBoxNotNullClick(Sender: TObject);
begin
// Not Null
fields[index].NotNull := CheckBoxNotNull.Checked;
cols[index].NotNull := CheckBoxNotNull.Checked;
end;
procedure TCreateTableForm.CheckBoxAutoincrementClick(Sender: TObject);
begin
// AutoIncrement
fields[index].AutoIncrement := CheckBoxAutoIncrement.Checked;
cols[index].AutoIncrement := CheckBoxAutoIncrement.Checked;
end;
procedure TCreateTableForm.Button1Click(Sender: TObject);
begin
// Add new Field
index := length(fields);
setlength(fields, index+1);
with fields[index] do
index := length(cols);
setlength(cols, index+1);
with cols[index] do
begin
Name := EditFieldName.Text;
FieldType := 0;
@ -471,7 +471,7 @@ begin
Autoincrement := false;
ListboxColumns.Items.Add(Name);
end;
refreshfields(self);
refreshColumnList(self);
EditFieldnameChange(self);
ListboxColumns.ItemIndex := index;
// Call change-handler of Tablename-edit to check if
@ -503,8 +503,8 @@ begin
// ListColumns Change
index := ListboxColumns.ItemIndex;
if index > -1 then
editfieldname.Text := fields[index].Name;
refreshfields(self);
editfieldname.Text := cols[index].Name;
refreshColumnList(self);
end;
procedure TCreateTableForm.FormShow(Sender: TObject);
@ -541,7 +541,7 @@ begin
index := -1;
setLength(fields, 0);
setLength(cols, 0);
ListboxColumns.Items.Clear;
EditTableName.Text := 'TableName';
EditFieldName.Text := 'FieldName';
@ -568,8 +568,8 @@ end;
procedure TCreateTableForm.ButtonChangeClick(Sender: TObject);
begin
// Change Fieldname
fields[index].Name := editfieldname.Text;
refreshfields(self);
cols[index].Name := editfieldname.Text;
refreshColumnList(self);
editfieldnamechange(self);
end;
@ -618,7 +618,7 @@ end;
procedure TCreateTableForm.fillControls(Sender: TObject);
begin
// fill controls with values
with fields[index] do
with cols[index] do
begin
ComboBoxType.ItemIndex := FieldType;
EditLengthSet.Text := LengthSet;
@ -639,25 +639,25 @@ end;
procedure TCreateTableForm.ButtonMoveUpClick(Sender: TObject);
begin
// move up
setlength(fields, length(fields)+1);
fields[length(fields)-1] := fields[index-1];
fields[index-1] := fields[index];
fields[index] := fields[length(fields)-1];
setlength(fields, length(fields)-1);
setlength(cols, length(cols)+1);
cols[length(cols)-1] := cols[index-1];
cols[index-1] := cols[index];
cols[index] := cols[length(cols)-1];
setlength(cols, length(cols)-1);
dec(index);
refreshfields(self);
refreshColumnList(self);
end;
procedure TCreateTableForm.ButtonMoveDownClick(Sender: TObject);
begin
// move down
setlength(fields, length(fields)+1);
fields[length(fields)-1] := fields[index+1];
fields[index+1] := fields[index];
fields[index] := fields[length(fields)-1];
setlength(fields, length(fields)-1);
setlength(cols, length(cols)+1);
cols[length(cols)-1] := cols[index+1];
cols[index+1] := cols[index];
cols[index] := cols[length(cols)-1];
setlength(cols, length(cols)-1);
inc(index);
refreshfields(self);
refreshColumnList(self);
end;

View File

@ -438,12 +438,12 @@ begin
// move field if position changed
if (ComboBoxPosition.ItemIndex > -1) and (FMode in [femFieldUpdate]) and (cwin.mysql_version < 40001) then
begin // Move field position
if MessageDLG('You are about to move a field''s position in the table-structure. While there is no handy one-query-method in MySQL to do that, this will be done in 4 steps:'+CRLF+
' 1. Adding a temporary field at the specified position'+CRLF+
' 2. Filling the temporary field with the same data as source field'+CRLF+
' 3. Dropping the source-field'+CRLF+
' 4. Renaming the temporary field to it''s original name.'+CRLF+CRLF+
'Be aware that this method can mess up existing indexes in your table or even can result in losing data! If you are not sure you should not use this function on indexed fields.'+CRLF+CRLF+
if MessageDLG('You are about to move a column''s position in the table definition. While there is no handy MySQL way to do that, this will be done in 4 steps:'+CRLF+
' 1. Add a temporary column at the specified position'+CRLF+
' 2. Fill the temporary column with the same data as the source column'+CRLF+
' 3. Drop the source column'+CRLF+
' 4. Rename the temporary column to the same name the source column had.'+CRLF+CRLF+
'Be aware that this method can mess up existing indexes in your table or even result in losing data! If you are not sure you should not use this function, especially on indexed columns.'+CRLF+CRLF+
'Continue?',
mtConfirmation,
[mbYes, mbCancel],

View File

@ -763,7 +763,7 @@ begin
' </style>' + crlf +
'</head>' + crlf + crlf +
'<body>' + crlf + crlf +
'<h3>' + htmltitle + ' (' + inttostr(Length(ds.Rows)) + ' Records)</h3>' + crlf + crlf +
'<h3>' + htmltitle + ' (' + inttostr(Length(ds.Rows)) + ' rows)</h3>' + crlf + crlf +
'<table >' + crlf +
' <tr id="header">' + crlf;
for j:=0 to Length(ds.Columns)-1 do

View File

@ -1462,7 +1462,7 @@ end;
procedure TMainForm.actDataDeleteExecute(Sender: TObject);
begin
// Delete record(s)
// Delete row(s)
if not Childwin.CheckUniqueKeyClause then
Exit;
if Childwin.DataGrid.SelectedCount = 0 then
@ -1514,7 +1514,7 @@ begin
// We allow the user to select and delete multiple listItems
dropList := GetVTCaptions( Childwin.ListColumns, True );
// User confirmation
if MessageDlg('Delete ' + IntToStr(dropList.Count) + ' field(s): ' + ImplodeStr( ', ', dropList ) + ' ?', mtConfirmation, [mbok,mbcancel], 0) = mrok then
if MessageDlg('Delete ' + IntToStr(dropList.Count) + ' column(s): ' + ImplodeStr( ', ', dropList ) + ' ?', mtConfirmation, [mbok,mbcancel], 0) = mrok then
try
// Concat fields for ALTER query
for i := 0 to dropList.Count - 1 do

View File

@ -293,7 +293,7 @@ begin
// Load users into memory
Users := TUsers.Create;
// Enable limitations editors only if relevant fields exist
// Enable limitations editors only if relevant columns exist
lblMaxQuestions.Enabled := dsUser.FindField('max_questions') <> nil;
editMaxQuestions.Enabled := lblMaxQuestions.Enabled;
udMaxQuestions.Enabled := lblMaxQuestions.Enabled;
@ -1121,7 +1121,7 @@ begin
end;
end;
PrivWhere := Delim(PrivUpdates);
// Assemble list of key fields for new privilege definition.
// Assemble list of key columns for new privilege definition.
PrivUpdates.Clear;
PrivValues.Clear;
// Assemble values of new privilege definition.
@ -1553,7 +1553,7 @@ begin
if cropNames.IndexOf(PrivNames[i]) = -1 then PrivNames.Delete(i);
end;
end;
// Find out what SET fields of tables_priv this server/version has.
// Find out what SET columns in tables_priv this server/version has.
// Only load tables_priv.Table_priv
i := PrivNames.IndexOf('Table_priv');
if i > -1 then begin
@ -1561,7 +1561,7 @@ begin
PrivNames.AddStrings(GetSETValues('Table'));
end;
tables_col_ignore := i > -1;
// Find out what SET fields of columns_priv this server/version has.
// Find out what SET columns in columns_priv this server/version has.
i := PrivNames.IndexOf('Column_priv');
if i > -1 then begin
PrivNames.Delete(i);