diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index eb0e9fc4..383c12eb 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -42,7 +42,7 @@ type procedure PickerKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure PickerChange(Sender: TObject); public - DataType: Byte; // @see mysql_structures + Datatype: TDatatypeIndex; // @see mysql_structures constructor Create; destructor Destroy; override; function BeginEdit: Boolean; virtual; stdcall; @@ -220,7 +220,7 @@ begin F := TFont.Create; FTree.GetTextInfo(Node, Column, F, FTextBounds, Text); - IsBinary := Mainform.FDataGridResult.Columns[Column].IsBinary; + IsBinary := Mainform.FDataGridResult.Columns[Column].DatatypeCat = dtcBinary; // Get wide text of the node. Text := FTree.Text[FNode, FColumn]; @@ -344,17 +344,17 @@ begin if Not Result then Exit; if FModified then begin - case DataType of - tpDATE: + case Datatype of + dtDate: newtext := FormatDateTime(ShortDateFormat, FDatePicker.Date); - tpDATETIME, tpTIMESTAMP: + dtDatetime, dtTimestamp: begin // Take date and add time dt := FDatePicker.Date; ReplaceTime(dt, FTimePicker.Time); newtext := FormatDateTime(ShortDateFormat+' '+LongTimeFormat, dt); end; - tpTIME: + dtTime: newtext := FormatDateTime(LongTimeFormat, FTimePicker.Time); end; if newtext <> FTree.Text[FNode, FColumn] then @@ -402,7 +402,7 @@ begin except dt := Now; end; - if DataType in [tpDATE, tpDATETIME, tpTIMESTAMP] then begin + if Datatype in [dtDate, dtDatetime, dtTimestamp] then begin FDatePicker := TDateTimePicker.Create(Tree); FDatePicker.Parent := FTree; FDatePicker.OnKeyDown := PickerKeyDown; @@ -411,7 +411,7 @@ begin FDatePicker.DateTime := dt; FDatePicker.OnChange := PickerChange; end; - if DataType in [tpDATETIME, tpTIMESTAMP, tpTIME] then begin + if Datatype in [dtDatetime, dtTimestamp, dtTime] then begin FTimePicker := TDateTimePicker.Create(Tree); FTimePicker.Parent := FTree; FTimePicker.OnKeyDown := PickerKeyDown; diff --git a/source/helpers.pas b/source/helpers.pas index 71a87f0e..358273b2 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -11,7 +11,7 @@ interface uses Classes, SysUtils, Graphics, db, clipbrd, dialogs, forms, controls, ShellApi, checklst, windows, ZDataset, ZAbstractDataset, shlobj, ActiveX, WideStrUtils, VirtualTrees, SynRegExpr, Messages, WideStrings, - TntCheckLst, Registry, SynEditHighlighter; + TntCheckLst, Registry, SynEditHighlighter, mysql_structures; type @@ -55,16 +55,10 @@ type PGridCell = ^TGridCell; TGridColumn = record Name: WideString; - DataType: Byte; // @see constants in mysql_structures.pas + Datatype: TDatatypeIndex; // @see mysql_structures.pas + DatatypeCat: TDatatypeCategoryIndex; MaxLength: Cardinal; IsPriPart: Boolean; - IsBinary: Boolean; - IsText: Boolean; - IsEnum: Boolean; - IsSet: Boolean; - IsInt: Boolean; - IsFloat: Boolean; - IsDate: Boolean; ValueList: TWideStringList; end; PGridColumn = ^TGridColumn; @@ -197,7 +191,6 @@ type function ListIndexByRegExpr(List: TWideStrings; Expression: WideString): Integer; procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter); var - MYSQL_KEYWORDS : TStringList; MainReg : TRegistry; @@ -944,7 +937,7 @@ begin Continue; Data := GridData.Columns[i].Name; // Alter column name in header if data is not raw. - if GridData.Columns[i].IsBinary then Data := 'HEX(' + Data + ')'; + if GridData.Columns[i].DatatypeCat = dtcBinary then Data := 'HEX(' + Data + ')'; // Add header item. if tmp <> '' then tmp := tmp + Separator; tmp := tmp + Encloser + Data + Encloser; @@ -968,9 +961,9 @@ begin Continue; Data := Grid.Text[Node, i]; // Remove 0x. - if GridData.Columns[i].IsBinary then Delete(Data, 1, 2); + if GridData.Columns[i].DatatypeCat = dtcBinary then Delete(Data, 1, 2); // Unformat float values - if GridData.Columns[i].IsFloat then Data := FloatStr(Data); + if GridData.Columns[i].DatatypeCat = dtcReal then Data := FloatStr(Data); // Escape encloser characters inside data per de-facto CSV. Data := WideStringReplace(Data, Encloser, Encloser + Encloser, [rfReplaceAll]); // Special handling for NULL (MySQL-ism, not de-facto CSV: unquote value) @@ -1040,13 +1033,13 @@ begin tmp := tmp + #9#9'<' + Grid.Header.Columns[i].Text; if GridData.Rows[Node.Index].Cells[i].IsNull then tmp := tmp + ' isnull="true" />' + CRLF else begin - if GridData.Columns[i].IsBinary then tmp := tmp + ' format="hex"'; + if GridData.Columns[i].DatatypeCat = dtcBinary then tmp := tmp + ' format="hex"'; tmp := tmp + '>'; Data := Grid.Text[Node, i]; // Remove 0x. - if GridData.Columns[i].IsBinary then Delete(Data, 1, 2); + if GridData.Columns[i].DatatypeCat = dtcBinary then Delete(Data, 1, 2); // Unformat float values - if GridData.Columns[i].IsFloat then Data := FloatStr(Data); + if GridData.Columns[i].DatatypeCat = dtcReal then Data := FloatStr(Data); // Escape XML control characters in data. Data := htmlentities(Data); // Add data and cell end tag. @@ -1120,9 +1113,9 @@ begin else begin Data := Grid.Text[Node, i]; // Remove 0x. - if GridData.Columns[i].IsBinary then Delete(Data, 1, 2); + if GridData.Columns[i].DatatypeCat = dtcBinary then Delete(Data, 1, 2); // Unformat float values - if GridData.Columns[i].IsFloat then Data := FloatStr(Data); + if GridData.Columns[i].DatatypeCat = dtcReal then Data := FloatStr(Data); // Add data and cell end tag. tmp := tmp + esc(Data); end; @@ -2986,50 +2979,6 @@ begin end; -initialization - - - -// Keywords copied from SynHighligherSQL -MYSQL_KEYWORDS := TStringList.Create; -MYSQL_KEYWORDS.CommaText := 'ACTION,AFTER,AGAINST,AGGREGATE,ALGORITHM,ALL,ALTER,ANALYZE,AND,ANY,AS,' + - 'ASC,AT,AUTO_INCREMENT,AVG_ROW_LENGTH,BACKUP,BEFORE,BEGIN,BENCHMARK,BETWEEN,BINLOG,BIT,' + - 'BOOL,BOTH,BY,CACHE,CALL,CASCADE,CASCADED,CHANGE,CHARACTER,CHARSET,CHECK,' + - 'CHECKSUM,CLIENT,COLLATE,COLLATION,COLUMN,COLUMNS,COMMENT,COMMIT,' + - 'COMMITTED,COMPLETION,CONCURRENT,CONNECTION,CONSISTENT,CONSTRAINT,' + - 'CONVERT,CONTAINS,CONTENTS,CREATE,CROSS,DATA,DATABASE,DATABASES,' + - 'DEALLOCATE,DEC,DEFAULT,DEFINER,DELAYED,DELAY_KEY_WRITE,DELETE,DESC,' + - 'DETERMINISTIC,DIRECTORY,DISABLE,DISCARD,DESCRIBE,DISTINCT,DISTINCTROW,' + - 'DIV,DROP,DUAL,DUMPFILE,DUPLICATE,EACH,ELSE,ENABLE,ENCLOSED,END,ENDS,' + - 'ENGINE,ENGINES,ESCAPE,ESCAPED,ERRORS,EVENT,EVENTS,EVERY,EXECUTE,EXISTS,' + - 'EXPANSION,EXPLAIN,FALSE,FIELDS,FILE,FIRST,FLUSH,FOR,FORCE,FOREIGN,FROM,' + - 'FULL,FULLTEXT,FUNCTION,FUNCTIONS,GLOBAL,GRANT,GRANTS,GROUP,HAVING,HELP,' + - 'HIGH_PRIORITY,HOSTS,IDENTIFIED,IGNORE,INDEX,INFILE,INNER,INSERT,' + - 'INSERT_METHOD,INSTALL,INT1,INT2,INT3,INT4,INT8,INTO,IO_THREAD,IS,' + - 'ISOLATION,INVOKER,JOIN,KEY,KEYS,KILL,LAST,LEADING,LEAVES,LEVEL,LESS,' + - 'LIKE,LIMIT,LINEAR,LINES,LIST,LOAD,LOCAL,LOCK,LOGS,LONG,LOW_PRIORITY,' + - 'MASTER,MASTER_HOST,MASTER_LOG_FILE,MASTER_LOG_POS,MASTER_CONNECT_RETRY,' + - 'MASTER_PASSWORD,MASTER_PORT,MASTER_SSL,MASTER_SSL_CA,MASTER_SSL_CAPATH,' + - 'MASTER_SSL_CERT,MASTER_SSL_CIPHER,MASTER_SSL_KEY,MASTER_USER,MATCH,' + - 'MAX_ROWS,MAXVALUE,MIDDLEINT,MIN_ROWS,MOD,MODE,MODIFY,MODIFIES,NAMES,' + - 'NATURAL,NEW,NO,NODEGROUP,NOT,NULL,OJ,OFFSET,OLD,ON,OPTIMIZE,OPTION,' + - 'OPTIONALLY,OPEN,OR,ORDER,OUTER,OUTFILE,PACK_KEYS,PARTIAL,PARTITION,' + - 'PARTITIONS,PLUGIN,PLUGINS,PREPARE,PRESERVE,PRIMARY,PRIVILEGES,PROCEDURE,' + - 'PROCESS,PROCESSLIST,QUERY,RAID_CHUNKS,RAID_CHUNKSIZE,RAID_TYPE,RANGE,' + - 'READ,REBUILD,REFERENCES,REGEXP,RELAY_LOG_FILE,RELAY_LOG_POS,RELOAD,' + - 'RENAME,REORGANIZE,REPAIR,REPEATABLE,REPLACE,REPLICATION,RESTRICT,RESET,' + - 'RESTORE,RETURN,RETURNS,REVOKE,RLIKE,ROLLBACK,ROLLUP,ROUTINE,ROW,' + - 'ROW_FORMAT,ROWS,SAVEPOINT,SCHEDULE,SCHEMA,SCHEMAS,SECURITY,SELECT,' + - 'SERIALIZABLE,SESSION,SET,SHARE,SHOW,SHUTDOWN,SIMPLE,SLAVE,SNAPSHOT,' + - 'SONAME,SQL,SQL_BIG_RESULT,SQL_BUFFER_RESULT,SQL_CACHE,' + - 'SQL_CALC_FOUND_ROWS,SQL_NO_CACHE,SQL_SMALL_RESULT,SQL_THREAD,START,' + - 'STARTING,STARTS,STATUS,STOP,STORAGE,STRAIGHT_JOIN,SUBPARTITION,' + - 'SUBPARTITIONS,SUPER,TABLE,TABLES,TABLESPACE,TEMPORARY,TERMINATED,THAN,' + - 'THEN,TO,TRAILING,TRANSACTION,TRIGGER,TRIGGERS,TRUE,TYPE,UNCOMMITTED,' + - 'UNINSTALL,UNIQUE,UNLOCK,UPDATE,UPGRADE,UNION,USAGE,USE,USING,VALUES,' + - 'VARIABLES,VARYING,VIEW,WARNINGS,WHERE,WITH,WORK,WRITE'; - - end. diff --git a/source/main.pas b/source/main.pas index 38cf5cb4..e80e6d91 100644 --- a/source/main.pas +++ b/source/main.pas @@ -2198,7 +2198,7 @@ begin if g = nil then begin messagebeep(MB_ICONASTERISK); exit; end; Screen.Cursor := crHourGlass; showstatus('Saving contents to file...'); - IsBinary := ActiveData.Columns[g.FocusedColumn].IsBinary; + IsBinary := ActiveData.Columns[g.FocusedColumn].DatatypeCat = dtcBinary; Header := WideHexToBin(Copy(g.Text[g.FocusedNode, g.FocusedColumn], 3, 20)); SaveBinary := false; @@ -3347,24 +3347,24 @@ begin rx.Expression := '^(tiny|small|medium|big)?int\b'; if rx.Exec(ColType) then begin col.Alignment := taRightJustify; - FDataGridResult.Columns[idx].IsInt := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcInteger; end; rx.Expression := '^(float|double|decimal)\b'; if rx.Exec(ColType) then begin col.Alignment := taRightJustify; - FDataGridResult.Columns[idx].IsFloat := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcReal; end; rx.Expression := '^(date|datetime|time(stamp)?)\b'; if rx.Exec(ColType) then begin - FDataGridResult.Columns[idx].IsDate := True; - if rx.Match[1] = 'date' then FDataGridResult.Columns[idx].DataType := tpDATE - else if rx.Match[1] = 'time' then FDataGridResult.Columns[idx].DataType := tpTIME - else if rx.Match[1] = 'timestamp' then FDataGridResult.Columns[idx].DataType := tpTIMESTAMP - else FDataGridResult.Columns[idx].DataType := tpDATETIME; + FDataGridResult.Columns[idx].DatatypeCat := dtcTemporal; + if rx.Match[1] = 'date' then FDataGridResult.Columns[idx].Datatype := dtDate + else if rx.Match[1] = 'time' then FDataGridResult.Columns[idx].Datatype := dtTime + else if rx.Match[1] = 'timestamp' then FDataGridResult.Columns[idx].Datatype := dtTimestamp + else FDataGridResult.Columns[idx].Datatype := dtDatetime; end; rx.Expression := '^((tiny|medium|long)?text|(var)?char)\b(\(\d+\))?'; if rx.Exec(ColType) then begin - FDataGridResult.Columns[idx].IsText := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcText; if rx.Match[4] <> '' then FDataGridResult.Columns[idx].MaxLength := MakeInt(rx.Match[4]) else if ColType = 'tinytext' then @@ -3383,16 +3383,16 @@ begin end; rx.Expression := '^((tiny|medium|long)?blob|(var)?binary|bit)\b'; if rx.Exec(ColType) then - FDataGridResult.Columns[idx].IsBinary := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcBinary; if Copy(ColType, 1, 5) = 'enum(' then begin - FDataGridResult.Columns[idx].IsEnum := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcIntegerNamed; FDataGridResult.Columns[idx].ValueList := WideStrings.TWideStringList.Create; FDataGridResult.Columns[idx].ValueList.QuoteChar := ''''; FDataGridResult.Columns[idx].ValueList.Delimiter := ','; FDataGridResult.Columns[idx].ValueList.DelimitedText := GetEnumValues(ColType); end; if Copy(ColType, 1, 4) = 'set(' then begin - FDataGridResult.Columns[idx].IsSet := True; + FDataGridResult.Columns[idx].DatatypeCat := dtcSetNamed; FDataGridResult.Columns[idx].ValueList := WideStrings.TWideStringList.Create; FDataGridResult.Columns[idx].ValueList.QuoteChar := ''''; FDataGridResult.Columns[idx].ValueList.Delimiter := ','; @@ -4297,17 +4297,17 @@ begin col.Options := col.Options - [coAllowClick]; FQueryGridResult.Columns[i].Name := ColName; if ds.Fields[i].DataType in [ftSmallint, ftInteger, ftWord, ftLargeint] then begin - FQueryGridResult.Columns[i].IsInt := True; + FQueryGridResult.Columns[i].DatatypeCat := dtcInteger; col.Alignment := taRightJustify; end else if ds.Fields[i].DataType in [ftFloat] then begin - FQueryGridResult.Columns[i].IsFloat := True; + FQueryGridResult.Columns[i].DatatypeCat := dtcReal; col.Alignment := taRightJustify; end else if ds.Fields[i].DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then - FQueryGridResult.Columns[i].IsDate := True + FQueryGridResult.Columns[i].DatatypeCat := dtcTemporal else if ds.Fields[i].DataType in [ftWideString, ftMemo, ftWideMemo] then - FQueryGridResult.Columns[i].IsText := True + FQueryGridResult.Columns[i].DatatypeCat := dtcText else if ds.Fields[i].DataType in [ftBlob] then - FQueryGridResult.Columns[i].IsBinary := True; + FQueryGridResult.Columns[i].DatatypeCat := dtcBinary; end; debug('mem: query column initialization complete.'); debug('mem: clearing and initializing query rows (internal data).'); @@ -4318,7 +4318,7 @@ begin FQueryGridResult.Rows[i].Loaded := True; SetLength(FQueryGridResult.Rows[i].Cells, ds.FieldCount); for j:=0 to ds.FieldCount-1 do begin - if FQueryGridResult.Columns[j].IsBinary then + if FQueryGridResult.Columns[j].DatatypeCat = dtcBinary then FQueryGridResult.Rows[i].Cells[j].Text := '0x' + BinToWideHex(ds.Fields[j].AsString) else FQueryGridResult.Rows[i].Cells[j].Text := ds.Fields[j].AsWideString; @@ -4547,9 +4547,9 @@ begin end; // Add keywords - for i := 0 to MYSQL_KEYWORDS.Count - 1 do begin - SynCompletionProposal1.InsertList.Add( MYSQL_KEYWORDS[i] ); - SynCompletionProposal1.ItemList.Add( WideFormat(ItemPattern, [ICONINDEX_KEYWORD, 'keyword', MYSQL_KEYWORDS[i]] ) ); + for i := 0 to MySQLKeywords.Count - 1 do begin + SynCompletionProposal1.InsertList.Add( MySQLKeywords[i] ); + SynCompletionProposal1.ItemList.Add( WideFormat(ItemPattern, [ICONINDEX_KEYWORD, 'keyword', MySQLKeywords[i]] ) ); end; end; @@ -5670,8 +5670,8 @@ begin begin // State of items in popupmenu menuHelp.Enabled := True; - for i := 0 to MYSQL_KEYWORDS.Count - 1 do - lboxQueryHelpers.Items.Add(MYSQL_KEYWORDS[i]); + for i := 0 to MySQLKeywords.Count - 1 do + lboxQueryHelpers.Items.Add(MySQLKeywords[i]); end; 3: // SQL Snippets @@ -7161,7 +7161,7 @@ begin SetLength(res.Rows[Node.Index].Cells, ds.Fields.Count); i := Node.Index; for j := 0 to ds.Fields.Count - 1 do begin - if res.Columns[j].IsBinary then + if res.Columns[j].DatatypeCat = dtcBinary then res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(ds.Fields[j].AsString) else res.Rows[i].Cells[j].Text := ds.Fields[j].AsWideString; @@ -7243,7 +7243,7 @@ begin for i := start to start + limit - 1 do begin SetLength(res.Rows[i].Cells, ds.Fields.Count); for j := 0 to ds.Fields.Count - 1 do begin - if res.Columns[j].IsBinary then + if res.Columns[j].DatatypeCat = dtcBinary then res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(ds.Fields[j].AsString) else res.Rows[i].Cells[j].Text := ds.Fields[j].AsWideString; @@ -7360,22 +7360,22 @@ begin else if vsSelected in Node.States then cl := clBlack // Numeric field - else if r.Columns[Column].isInt or r.Columns[Column].isFloat then + else if r.Columns[Column].DatatypeCat in [dtcInteger, dtcReal] then if isNull then cl := prefNullColorNumeric else cl := prefFieldColorNumeric // Date field - else if r.Columns[Column].isDate then + else if r.Columns[Column].DatatypeCat = dtcTemporal then if isNull then cl := prefNullColorDatetime else cl := prefFieldColorDatetime // Text field - else if r.Columns[Column].isText then + else if r.Columns[Column].DatatypeCat = dtcText then if isNull then cl := prefNullColorText else cl := prefFieldColorText // Text field - else if r.Columns[Column].isBinary then + else if r.Columns[Column].DatatypeCat = dtcBinary then if isNull then cl := prefNullColorBinary else cl := prefFieldColorBinary // Enum field - else if r.Columns[Column].isEnum then + else if r.Columns[Column].DatatypeCat = dtcIntegerNamed then if isNull then cl := prefNullColorEnum else cl := prefFieldColorEnum // Set field - else if r.Columns[Column].isSet then + else if r.Columns[Column].DatatypeCat = dtcSetNamed then if isNull then cl := prefNullColorSet else cl := prefFieldColorSet else if isNull then cl := prefNullColorDefault else cl := clWindowText; @@ -7563,9 +7563,9 @@ begin for i := 0 to Length(FDataGridResult.Columns) - 1 do begin if Row.Cells[i].Modified then begin Val := Row.Cells[i].NewText; - if FDataGridResult.Columns[i].IsFloat then + if FDataGridResult.Columns[i].DatatypeCat = dtcReal then Val := FloatStr(Val) - else if FDataGridResult.Columns[i].IsBinary then begin + else if FDataGridResult.Columns[i].DatatypeCat = dtcBinary then begin CheckHex(Copy(Val, 3), 'Invalid hexadecimal string given in field "' + FDataGridResult.Columns[i].Name + '".'); if Val = '0x' then Val := esc(''); end else @@ -7648,9 +7648,9 @@ begin // Find old value of key column KeyVal := Row.Cells[j].Text; // Quote if needed - if FDataGridResult.Columns[j].IsFloat then + if FDataGridResult.Columns[j].DatatypeCat = dtcReal then KeyVal := FloatStr(KeyVal) - else if FDataGridResult.Columns[j].IsBinary then begin + else if FDataGridResult.Columns[j].DatatypeCat = dtcBinary then begin if KeyVal = '0x' then KeyVal := esc(''); end else @@ -7768,9 +7768,9 @@ begin if Row.Cells[i].Modified then begin Cols := Cols + mask(FDataGridResult.Columns[i].Name) + ', '; Val := Row.Cells[i].NewText; - if FDataGridResult.Columns[i].IsFloat then + if FDataGridResult.Columns[i].DatatypeCat = dtcReal then Val := FloatStr(Val) - else if FDataGridResult.Columns[i].IsBinary then begin + else if FDataGridResult.Columns[i].DatatypeCat = dtcBinary then begin CheckHex(Copy(Val, 3), 'Invalid hexadecimal string given in field "' + FDataGridResult.Columns[i].Name + '".'); if Val = '0x' then Val := esc(''); @@ -7934,7 +7934,7 @@ begin Cell := @Data.Rows[Node.Index].Cells[Column]; len := Length(Cell.Text); // Recalculate due to textual formatting of raw binary data. - if (Col.IsBinary) and (len > 2) then len := (len - 2) div 2; + if (Col.DatatypeCat = dtcBinary) and (len > 2) then len := (len - 2) div 2; // Assume width limit in effect if data exactly at limit threshold. if len = GridMaxData then begin if CheckUniqueKeyClause then begin @@ -7944,7 +7944,7 @@ begin ' WHERE ' + GetWhereClause(Row, @Data.Columns) ; ds := GetResults(sql); - if Col.IsBinary then Cell.Text := '0x' + BinToWideHex(ds.Fields[0].AsString) + if Col.DatatypeCat = dtcBinary then Cell.Text := '0x' + BinToWideHex(ds.Fields[0].AsString) else Cell.Text := ds.Fields[0].AsWideString; Cell.IsNull := ds.Fields[0].IsNull; end else @@ -7993,25 +7993,27 @@ var EnumEditor: TEnumEditorLink; SetEditor: TSetEditorLink; InplaceEditor: TInplaceEditorLink; + TypeCat: TDatatypeCategoryIndex; begin - if FDataGridResult.Columns[Column].IsText then begin + TypeCat := FDataGridResult.Columns[Column].DatatypeCat; + if TypeCat = dtcText then begin InplaceEditor := TInplaceEditorLink.Create(Sender as TVirtualStringTree); InplaceEditor.MaxLength := FDataGridResult.Columns[Column].MaxLength; InplaceEditor.ButtonVisible := true; EditLink := InplaceEditor; - end else if FDataGridResult.Columns[Column].IsBinary and prefEnableBinaryEditor then begin + end else if (TypeCat = dtcBinary) and prefEnableBinaryEditor then begin MemoEditor := TMemoEditorLink.Create; MemoEditor.MaxLength := FDataGridResult.Columns[Column].MaxLength; EditLink := MemoEditor; - end else if FDataGridResult.Columns[Column].IsDate and prefEnableDatetimeEditor then begin + end else if (TypeCat = dtcTemporal) and prefEnableDatetimeEditor then begin DateTimeEditor := TDateTimeEditorLink.Create; - DateTimeEditor.DataType := FDataGridResult.Columns[Column].DataType; + DateTimeEditor.Datatype := FDataGridResult.Columns[Column].Datatype; EditLink := DateTimeEditor; - end else if FDataGridResult.Columns[Column].IsEnum and prefEnableEnumEditor then begin + end else if (TypeCat = dtcIntegerNamed) and prefEnableEnumEditor then begin EnumEditor := TEnumEditorLink.Create; EnumEditor.ValueList := FDataGridResult.Columns[Column].ValueList; EditLink := EnumEditor; - end else if FDataGridResult.Columns[Column].IsSet and prefEnableSetEditor then begin + end else if (TypeCat = dtcSetNamed) and prefEnableSetEditor then begin SetEditor := TSetEditorLink.Create; SetEditor.ValueList := FDataGridResult.Columns[Column].ValueList; EditLink := SetEditor; diff --git a/source/mysql_structures.pas b/source/mysql_structures.pas index 9da38744..a9047df0 100644 --- a/source/mysql_structures.pas +++ b/source/mysql_structures.pas @@ -12,19 +12,22 @@ uses {$I const.inc} type - // MySQL Index structure - TMysqlIndex = record - Name: WideString; - Columns: TWideStringList; - Unique: Boolean; - Fulltext: Boolean; - Modified: Boolean; - Ready: Boolean; - end; + // MySQL data types + TDatatypeIndex = (dtTinyint, dtSmallint, dtMediumint, dtInt, dtBigint, + dtFloat, dtDouble, dtDecimal, + dtDate, dtTime, dtYear, dtDatetime, dtTimestamp, + dtChar, dtVarchar, dtTinytext, dtText, dtMediumtext, dtLongtext, + dtBinary, dtVarbinary, dtTinyblob, dtBlob, dtMediumblob, dtLongblob, + dtEnum, dtSet, dtBit, + dtPoint, dtLinestring, dtPolygon, dtGeometry, dtMultipoint, dtMultilinestring, dtMultipolygon, dtGeometrycollection); - // MySQL Data Type structure - TMysqlDataTypeRecord = record - Index: Integer; + // MySQL data type categorization + TDatatypeCategoryIndex = (dtcInteger, dtcReal, dtcTemporal, dtcText, dtcBinary, + dtcIntegerNamed, dtcSet, dtcSetNamed, dtcSpatial); + + // MySQL data type structure + TDatatype = record + Index: TDatatypeIndex; Name: String[18]; HasLength: Boolean; // Can have Length- or Set-attribute? RequiresLength: Boolean; // Must have a Length- or Set-attribute? @@ -33,32 +36,16 @@ type HasBinary: Boolean; // Can be binary? HasDefault: Boolean; // Can have a default value? DefLengthSet: String; // Should be set for types which require a length/set - Category: Integer; + Category: TDatatypeCategoryIndex; end; - // MySQL Data Type category structure - TMysqlDataTypeCategory = record - Index: Integer; + // MySQL data type category structure + TDatatypeCategory = record + Index: TDatatypeCategoryIndex; Name: String[32]; end; - // MySQL Field structure - TMysqlField = record - Name: String[64]; - FieldType: Byte; - LengthSet: String; - Default: String; - Primary: Boolean; - Index: Boolean; - Unique: Boolean; - Binary: Boolean; - Unsigned: Boolean; - Zerofill: Boolean; - NotNull: Boolean; - AutoIncrement: Boolean; - end; - - // MySQL Functions structure + // MySQL functions structure TMySQLFunction = record Name: String; Declaration: String; @@ -67,105 +54,54 @@ type Description: String; end; - - -// MySQL Field Types Constants -const - tpTINYINT = 0; - tpSMALLINT = 1; - tpMEDIUMINT = 2; - tpINT = 3; - tpBIGINT = 4; - tpFLOAT = 5; - tpDOUBLE = 6; - tpDECIMAL = 7; - tpDATE = 8; - tpTIME = 9; - tpYEAR = 10; - tpDATETIME = 11; - tpTIMESTAMP = 12; - tpCHAR = 13; - tpVARCHAR = 14; - tpTINYTEXT = 15; - tpTEXT = 16; - tpMEDIUMTEXT = 17; - tpLONGTEXT = 18; - tpBINARY = 19; - tpVARBINARY = 20; - tpTINYBLOB = 21; - tpBLOB = 22; - tpMEDIUMBLOB = 23; - tpLONGBLOB = 24; - tpENUM = 25; - tpSET = 26; - tpBIT = 27; - tpPOINT = 28; - tpLINESTRING = 29; - tpPOLYGON = 30; - tpGEOMETRY = 31; - tpMULTIPOINT = 32; - tpMULTILINESTRING = 33; - tpMULTIPOLYGON = 34; - tpGEOMETRYCOLLECTION = 35; - - // MySQL field type categorization -const - catInteger = 0; - catReal = 1; - catTemporal = 2; - catText = 3; - catBinary = 4; - catIntegerNamed = 5; - catSet = 6; - catSetNamed = 7; - catSpatial = 8; - var + MySQLKeywords: TStringList; + // MySQL data type categories - MySqlDataTypeCategories: array[0..8] of TMysqlDataTypeCategory = ( + DatatypeCategories: array[0..8] of TDatatypeCategory = ( ( - Index: catInteger; + Index: dtcInteger; Name: 'Integer' ), ( - Index: catIntegerNamed; + Index: dtcIntegerNamed; Name: 'Integer, named (nonstandard)' ), ( - Index: catReal; + Index: dtcReal; Name: 'Real' ), ( - Index: catText; + Index: dtcText; Name: 'Text' ), ( - Index: catBinary; + Index: dtcBinary; Name: 'Binary' ), ( - Index: catTemporal; + Index: dtcTemporal; Name: 'Temporal (time)' ), ( - Index: catSpatial; + Index: dtcSpatial; Name: 'Spatial (geometry)' ), ( - Index: catSet; + Index: dtcSet; Name: 'Set of Bits (nonstandard)' ), ( - Index: catSetNamed; + Index: dtcSetNamed; Name: 'Set of Bits, named (nonstandard)' ) ); // MySQL Data Type List and Properties - MySqlDataTypeArray: array [0..35] of TMysqlDataTypeRecord = + Datatypes: array [0..35] of TDatatype = ( ( - Index: tpTINYINT; + Index: dtTinyint; Name: 'TINYINT'; HasLength: True; RequiresLength: False; @@ -173,10 +109,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catInteger; + Category: dtcInteger; ), ( - Index: tpSMALLINT; + Index: dtSmallint; Name: 'SMALLINT'; HasLength: True; RequiresLength: False; @@ -184,10 +120,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catInteger; + Category: dtcInteger; ), ( - Index: tpMEDIUMINT; + Index: dtMediumint; Name: 'MEDIUMINT'; HasLength: True; RequiresLength: False; @@ -195,10 +131,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catInteger; + Category: dtcInteger; ), ( - Index: tpINT; + Index: dtInt; Name: 'INT'; HasLength: True; RequiresLength: False; @@ -206,10 +142,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catInteger; + Category: dtcInteger; ), ( - Index: tpBIGINT; + Index: dtBigint; Name: 'BIGINT'; HasLength: True; RequiresLength: False; @@ -217,10 +153,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catInteger; + Category: dtcInteger; ), ( - Index: tpFLOAT; + Index: dtFloat; Name: 'FLOAT'; HasLength: True; RequiresLength: False; @@ -228,10 +164,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catReal; + Category: dtcReal; ), ( - Index: tpDOUBLE; + Index: dtDouble; Name: 'DOUBLE'; HasLength: True; RequiresLength: False; @@ -239,10 +175,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catReal; + Category: dtcReal; ), ( - Index: tpDECIMAL; + Index: dtDecimal; Name: 'DECIMAL'; HasLength: True; RequiresLength: True; @@ -250,10 +186,10 @@ var HasZerofill: True; HasBinary: False; HasDefault: True; - Category: catReal; + Category: dtcReal; ), ( - Index: tpDATE; + Index: dtDate; Name: 'DATE'; HasLength: False; RequiresLength: False; @@ -261,10 +197,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catTemporal; + Category: dtcTemporal; ), ( - Index: tpTIME; + Index: dtTime; Name: 'TIME'; HasLength: False; RequiresLength: False; @@ -272,10 +208,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catTemporal; + Category: dtcTemporal; ), ( - Index: tpYEAR; + Index: dtYear; Name: 'YEAR'; HasLength: False; RequiresLength: False; @@ -283,10 +219,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catTemporal; + Category: dtcTemporal; ), ( - Index: tpDATETIME; + Index: dtDatetime; Name: 'DATETIME'; HasLength: False; RequiresLength: False; @@ -294,10 +230,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catTemporal; + Category: dtcTemporal; ), ( - Index: tpTIMESTAMP; + Index: dtTimestamp; Name: 'TIMESTAMP'; HasLength: False; RequiresLength: False; @@ -305,10 +241,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catTemporal; + Category: dtcTemporal; ), ( - Index: tpCHAR; + Index: dtCHAR; Name: 'CHAR'; HasLength: True; RequiresLength: True; @@ -317,10 +253,10 @@ var HasBinary: True; HasDefault: True; DefLengthSet: '50'; - Category: catText; + Category: dtcText; ), ( - Index: tpVARCHAR; + Index: dtVarchar; Name: 'VARCHAR'; HasLength: True; RequiresLength: True; @@ -329,10 +265,10 @@ var HasBinary: True; // MySQL-Help says the opposite but it's valid for older versions at least. HasDefault: True; DefLengthSet: '50'; - Category: catText; + Category: dtcText; ), ( - Index: tpTINYTEXT; + Index: dtTinytext; Name: 'TINYTEXT'; HasLength: False; RequiresLength: False; @@ -340,10 +276,10 @@ var HasZerofill: False; HasBinary: True; HasDefault: False; - Category: catText; + Category: dtcText; ), ( - Index: tpTEXT; + Index: dtText; Name: 'TEXT'; HasLength: False; RequiresLength: False; @@ -351,10 +287,10 @@ var HasZerofill: False; HasBinary: True; HasDefault: False; - Category: catText; + Category: dtcText; ), ( - Index: tpMEDIUMTEXT; + Index: dtMediumtext; Name: 'MEDIUMTEXT'; HasLength: False; RequiresLength: False; @@ -362,10 +298,10 @@ var HasZerofill: False; HasBinary: True; HasDefault: False; - Category: catText; + Category: dtcText; ), ( - Index: tpLONGTEXT; + Index: dtLongtext; Name: 'LONGTEXT'; HasLength: False; RequiresLength: False; @@ -373,10 +309,10 @@ var HasZerofill: False; HasBinary: True; HasDefault: False; - Category: catText; + Category: dtcText; ), ( - Index: tpBINARY; + Index: dtBinary; Name: 'BINARY'; HasLength: True; RequiresLength: True; @@ -385,10 +321,10 @@ var HasBinary: False; HasDefault: True; DefLengthSet: '50'; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpVARBINARY; + Index: dtVarbinary; Name: 'VARBINARY'; HasLength: True; RequiresLength: True; @@ -397,10 +333,10 @@ var HasBinary: False; HasDefault: True; DefLengthSet: '50'; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpTINYBLOB; + Index: dtTinyblob; Name: 'TINYBLOB'; HasLength: False; RequiresLength: False; @@ -408,10 +344,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpBLOB; + Index: dtBlob; Name: 'BLOB'; HasLength: False; RequiresLength: False; @@ -419,10 +355,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpMEDIUMBLOB; + Index: dtMediumblob; Name: 'MEDIUMBLOB'; HasLength: False; RequiresLength: False; @@ -430,10 +366,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpLONGBLOB; + Index: dtLongblob; Name: 'LONGBLOB'; HasLength: False; RequiresLength: False; @@ -441,10 +377,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catBinary; + Category: dtcBinary; ), ( - Index: tpENUM; + Index: dtEnum; Name: 'ENUM'; HasLength: True; // Obviously this is not meant as "length", but as "set of values" RequiresLength: True; @@ -453,10 +389,10 @@ var HasBinary: False; HasDefault: True; DefLengthSet: '''Y'',''N'''; - Category: catIntegerNamed; + Category: dtcIntegerNamed; ), ( - Index: tpSET; + Index: dtSet; Name: 'SET'; HasLength: True; // Same as for ENUM RequiresLength: True; @@ -465,10 +401,10 @@ var HasBinary: False; HasDefault: True; DefLengthSet: '''Value A'',''Value B'''; - Category: catSetNamed; + Category: dtcSetNamed; ), ( - Index: tpBIT; + Index: dtBit; Name: 'BIT'; HasLength: True; RequiresLength: False; @@ -476,10 +412,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: True; - Category: catSet; + Category: dtcSet; ), ( - Index: tpPOINT; + Index: dtPoint; Name: 'POINT'; HasLength: False; RequiresLength: False; @@ -487,10 +423,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpLINESTRING; + Index: dtLinestring; Name: 'LINESTRING'; HasLength: False; RequiresLength: False; @@ -498,10 +434,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpPOLYGON; + Index: dtPolygon; Name: 'POLYGON'; HasLength: False; RequiresLength: False; @@ -509,10 +445,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpGEOMETRY; + Index: dtGeometry; Name: 'GEOMETRY'; HasLength: False; RequiresLength: False; @@ -520,10 +456,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpMULTIPOINT; + Index: dtMultipoint; Name: 'MULTIPOINT'; HasLength: False; RequiresLength: False; @@ -531,10 +467,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpMULTILINESTRING; + Index: dtMultilinestring; Name: 'MULTILINESTRING'; HasLength: False; RequiresLength: False; @@ -542,10 +478,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpMULTIPOLYGON; + Index: dtMultipolygon; Name: 'MULTIPOLYGON'; HasLength: False; RequiresLength: False; @@ -553,10 +489,10 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ), ( - Index: tpGEOMETRYCOLLECTION; + Index: dtGeometrycollection; Name: 'GEOMETRYCOLLECTION'; HasLength: False; RequiresLength: False; @@ -564,7 +500,7 @@ var HasZerofill: False; HasBinary: False; HasDefault: False; - Category: catSpatial; + Category: dtcSpatial; ) ); @@ -4167,7 +4103,7 @@ var ); function GetFunctionCategories: TStringList; - function GetDatatypeByName(Datatype: String): TMysqlDataTypeRecord; + function GetDatatypeByName(Datatype: String): TDatatype; implementation @@ -4187,17 +4123,58 @@ begin end; -function GetDatatypeByName(Datatype: String): TMysqlDataTypeRecord; +function GetDatatypeByName(Datatype: String): TDatatype; var i: Integer; begin - for i:=Low(MySqlDataTypeArray) to High(MySqlDataTypeArray) do begin - if MySqlDataTypeArray[i].Name = Datatype then begin - Result := MySqlDataTypeArray[i]; + for i:=Low(Datatypes) to High(Datatypes) do begin + if Datatypes[i].Name = Datatype then begin + Result := Datatypes[i]; break; end; end; end; +initialization + +// Keywords copied from SynHighligherSQL +MySQLKeywords := TStringList.Create; +MySQLKeywords.CommaText := 'ACTION,AFTER,AGAINST,AGGREGATE,ALGORITHM,ALL,ALTER,ANALYZE,AND,ANY,AS,' + + 'ASC,AT,AUTO_INCREMENT,AVG_ROW_LENGTH,BACKUP,BEFORE,BEGIN,BENCHMARK,BETWEEN,BINLOG,BIT,' + + 'BOOL,BOTH,BY,CACHE,CALL,CASCADE,CASCADED,CHANGE,CHARACTER,CHARSET,CHECK,' + + 'CHECKSUM,CLIENT,COLLATE,COLLATION,COLUMN,COLUMNS,COMMENT,COMMIT,' + + 'COMMITTED,COMPLETION,CONCURRENT,CONNECTION,CONSISTENT,CONSTRAINT,' + + 'CONVERT,CONTAINS,CONTENTS,CREATE,CROSS,DATA,DATABASE,DATABASES,' + + 'DEALLOCATE,DEC,DEFAULT,DEFINER,DELAYED,DELAY_KEY_WRITE,DELETE,DESC,' + + 'DETERMINISTIC,DIRECTORY,DISABLE,DISCARD,DESCRIBE,DISTINCT,DISTINCTROW,' + + 'DIV,DROP,DUAL,DUMPFILE,DUPLICATE,EACH,ELSE,ENABLE,ENCLOSED,END,ENDS,' + + 'ENGINE,ENGINES,ESCAPE,ESCAPED,ERRORS,EVENT,EVENTS,EVERY,EXECUTE,EXISTS,' + + 'EXPANSION,EXPLAIN,FALSE,FIELDS,FILE,FIRST,FLUSH,FOR,FORCE,FOREIGN,FROM,' + + 'FULL,FULLTEXT,FUNCTION,FUNCTIONS,GLOBAL,GRANT,GRANTS,GROUP,HAVING,HELP,' + + 'HIGH_PRIORITY,HOSTS,IDENTIFIED,IGNORE,INDEX,INFILE,INNER,INSERT,' + + 'INSERT_METHOD,INSTALL,INT1,INT2,INT3,INT4,INT8,INTO,IO_THREAD,IS,' + + 'ISOLATION,INVOKER,JOIN,KEY,KEYS,KILL,LAST,LEADING,LEAVES,LEVEL,LESS,' + + 'LIKE,LIMIT,LINEAR,LINES,LIST,LOAD,LOCAL,LOCK,LOGS,LONG,LOW_PRIORITY,' + + 'MASTER,MASTER_HOST,MASTER_LOG_FILE,MASTER_LOG_POS,MASTER_CONNECT_RETRY,' + + 'MASTER_PASSWORD,MASTER_PORT,MASTER_SSL,MASTER_SSL_CA,MASTER_SSL_CAPATH,' + + 'MASTER_SSL_CERT,MASTER_SSL_CIPHER,MASTER_SSL_KEY,MASTER_USER,MATCH,' + + 'MAX_ROWS,MAXVALUE,MIDDLEINT,MIN_ROWS,MOD,MODE,MODIFY,MODIFIES,NAMES,' + + 'NATURAL,NEW,NO,NODEGROUP,NOT,NULL,OJ,OFFSET,OLD,ON,OPTIMIZE,OPTION,' + + 'OPTIONALLY,OPEN,OR,ORDER,OUTER,OUTFILE,PACK_KEYS,PARTIAL,PARTITION,' + + 'PARTITIONS,PLUGIN,PLUGINS,PREPARE,PRESERVE,PRIMARY,PRIVILEGES,PROCEDURE,' + + 'PROCESS,PROCESSLIST,QUERY,RAID_CHUNKS,RAID_CHUNKSIZE,RAID_TYPE,RANGE,' + + 'READ,REBUILD,REFERENCES,REGEXP,RELAY_LOG_FILE,RELAY_LOG_POS,RELOAD,' + + 'RENAME,REORGANIZE,REPAIR,REPEATABLE,REPLACE,REPLICATION,RESTRICT,RESET,' + + 'RESTORE,RETURN,RETURNS,REVOKE,RLIKE,ROLLBACK,ROLLUP,ROUTINE,ROW,' + + 'ROW_FORMAT,ROWS,SAVEPOINT,SCHEDULE,SCHEMA,SCHEMAS,SECURITY,SELECT,' + + 'SERIALIZABLE,SESSION,SET,SHARE,SHOW,SHUTDOWN,SIMPLE,SLAVE,SNAPSHOT,' + + 'SONAME,SQL,SQL_BIG_RESULT,SQL_BUFFER_RESULT,SQL_CACHE,' + + 'SQL_CALC_FOUND_ROWS,SQL_NO_CACHE,SQL_SMALL_RESULT,SQL_THREAD,START,' + + 'STARTING,STARTS,STATUS,STOP,STORAGE,STRAIGHT_JOIN,SUBPARTITION,' + + 'SUBPARTITIONS,SUPER,TABLE,TABLES,TABLESPACE,TEMPORARY,TERMINATED,THAN,' + + 'THEN,TO,TRAILING,TRANSACTION,TRIGGER,TRIGGERS,TRUE,TYPE,UNCOMMITTED,' + + 'UNINSTALL,UNIQUE,UNLOCK,UPDATE,UPGRADE,UNION,USAGE,USE,USING,VALUES,' + + 'VARIABLES,VARYING,VIEW,WARNINGS,WHERE,WITH,WORK,WRITE'; + end. diff --git a/source/routine_editor.pas b/source/routine_editor.pas index ddc40552..77964dac 100644 --- a/source/routine_editor.pas +++ b/source/routine_editor.pas @@ -105,8 +105,8 @@ begin comboDataAccess.Items.Add('Modifies SQL data'); comboSecurity.Items.Add('Definer'); comboSecurity.Items.Add('Invoker'); - for i := Low(MySqlDataTypeArray) to High(MySqlDataTypeArray) do - comboReturns.Items.Add(MySqlDataTypeArray[i].Name); + for i := Low(Datatypes) to High(Datatypes) do + comboReturns.Items.Add(Datatypes[i].Name); SetWindowSizeGrip(Handle, True); InheritFont(Font); FixVT(listParameters); @@ -336,8 +336,8 @@ begin EnumEditor := TEnumEditorLink.Create; EnumEditor.AllowCustomText := True; EnumEditor.ValueList := TWideStringList.Create; - for i:=Low(MySqlDataTypeArray) to High(MySqlDataTypeArray) do - EnumEditor.ValueList.Add(MySqlDataTypeArray[i].Name); + for i:=Low(Datatypes) to High(Datatypes) do + EnumEditor.ValueList.Add(Datatypes[i].Name); EditLink := EnumEditor; end else if Column = 3 then begin EnumEditor := TEnumEditorLink.Create; diff --git a/source/table_editor.pas b/source/table_editor.pas index c172fb63..4c6f27dd 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -434,7 +434,7 @@ var ColSpec, IndexSQL, DefaultText: WideString; i, j: Integer; AddIt, DropIt: Boolean; - dt: TMySQLDataTypeRecord; + dt: TDatatype; DefaultType: TColumnDefaultType; ds: TDataset; begin @@ -570,7 +570,7 @@ function TfrmTableEditor.ComposeCreateStatement: WideString; var i, IndexCount: Integer; ColProps: TWideStringlist; - dt: TMySQLDataTypeRecord; + dt: TDatatype; DefaultType: TColumnDefaultType; DefaultText, tmp: WideString; begin @@ -888,7 +888,7 @@ end; function TfrmTableEditor.CellEditingAllowed(Node: PVirtualNode; Column: TColumnIndex): Boolean; var Props: TWideStringlist; - dt: TMysqlDataTypeRecord; + dt: TDatatype; begin Props := TWideStringlist(Columns.Objects[Node.Index]); dt := GetDatatypeByName(Props[0]); @@ -933,7 +933,7 @@ procedure TfrmTableEditor.listColumnsPaintText(Sender: TBaseVirtualTree; var Datatype: String; TextColor: TColor; - dt: TMySQLDatatypeRecord; + dt: TDatatype; begin // Give datatype column specific color, as set in preferences if vsSelected in Node.States then @@ -945,12 +945,12 @@ begin dt := GetDatatypeByName(Datatype); case dt.Category of - catInteger, catReal: TextColor := Mainform.prefFieldColorNumeric; - catTemporal: TextColor := Mainform.prefFieldColorDateTime; - catText: TextColor := Mainform.prefFieldColorText; - catBinary: TextColor := Mainform.prefFieldColorBinary; - catIntegerNamed: TextColor := Mainform.prefFieldColorEnum; - catSet, catSetNamed: TextColor := Mainform.prefFieldColorSet; + dtcInteger, dtcReal: TextColor := Mainform.prefFieldColorNumeric; + dtcTemporal: TextColor := Mainform.prefFieldColorDateTime; + dtcText: TextColor := Mainform.prefFieldColorText; + dtcBinary: TextColor := Mainform.prefFieldColorBinary; + dtcIntegerNamed: TextColor := Mainform.prefFieldColorEnum; + dtcSet, dtcSetNamed: TextColor := Mainform.prefFieldColorSet; // TODO: catSpatial else TextColor := TargetCanvas.Font.Color; end; @@ -1044,8 +1044,8 @@ begin 2: begin // Datatype pulldown EnumEditor := TEnumEditorLink.Create; EnumEditor.ValueList := TWideStringList.Create; - for i:=Low(MySqlDataTypeArray) to High(MySqlDataTypeArray) do - EnumEditor.ValueList.Add(MySqlDataTypeArray[i].Name); + for i:=Low(Datatypes) to High(Datatypes) do + EnumEditor.ValueList.Add(Datatypes[i].Name); EditLink := EnumEditor; end; 8: begin // Collation pulldown