From eefdbec81c07258a9aa9dd0e5af17079b23d0d13 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 9 Dec 2009 20:03:46 +0000 Subject: [PATCH] Render primary key columns in query results in bold font, like in data grid. --- source/main.pas | 1 + source/mysql_connection.pas | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/source/main.pas b/source/main.pas index 213b9722..d49925a4 100644 --- a/source/main.pas +++ b/source/main.pas @@ -3988,6 +3988,7 @@ begin ActiveGridResult.Columns[i].DatatypeCat := Results.DataType(i).Category; if ActiveGridResult.Columns[i].DatatypeCat in [dtcInteger, dtcReal] then col.Alignment := taRightJustify; + ActiveGridResult.Columns[i].IsPriPart := Results.ColIsPrimaryKeyPart(i); end; debug('mem: query column initialization complete.'); debug('mem: clearing and initializing query rows (internal data).'); diff --git a/source/mysql_connection.pas b/source/mysql_connection.pas index dd0be58e..de59ac7f 100644 --- a/source/mysql_connection.pas +++ b/source/mysql_connection.pas @@ -184,6 +184,7 @@ type function Col(ColumnName: WideString; IgnoreErrors: Boolean=False): WideString; overload; function DataType(Column: Integer): TDataType; function ColExists(Column: WideString): Boolean; + function ColIsPrimaryKeyPart(Column: Integer): Boolean; function IsNull(Column: Integer): Boolean; function HasResult: Boolean; property RecNo: Int64 read FRecNo write SetRecNo; @@ -932,6 +933,18 @@ begin end; +function TMySQLQuery.ColIsPrimaryKeyPart(Column: Integer): Boolean; +var + Field: PMYSQL_FIELD; +begin + if HasResult and (Column < ColumnCount) then begin + Field := mysql_fetch_field_direct(FLastResult, Column); + Result := (Field.flags and PRI_KEY_FLAG) = PRI_KEY_FLAG; + end else + Result := False; +end; + + function TMySQLQuery.IsNull(Column: Integer): Boolean; begin Result := FCurrentRow[Column] = nil;