From 0a5406834cc16dbc8fb3ca8f685ba18aa0098b34 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 28 Nov 2018 21:18:25 +0100 Subject: [PATCH] Cast date/time columns to char on MySQL when generating an all-column filter. Closes #392. --- source/dbconnection.pas | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index eafe4b05..64ffee3c 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -7428,12 +7428,20 @@ function TTableColumn.CastAsText: String; begin // Cast data types which are incompatible to string functions to text columns Result := FConnection.QuoteIdent(Name); - if DataType.Index = dtUnknown then - case FConnection.Parameters.NetTypeGroup of - ngMySQL: Result := 'CAST('+Result+' AS CHAR)'; - ngMSSQL: Result := 'CAST('+Result+' AS NVARCHAR('+IntToStr(SIZE_MB)+'))'; - ngPgSQL: Result := Result + '::text'; + case FConnection.Parameters.NetTypeGroup of + ngMySQL: begin + if DataType.Index in [dtUnknown, dtDate, dtDatetime, dtTime, dtTimestamp] then + Result := 'CAST('+Result+' AS CHAR)'; end; + ngMSSQL: begin + if DataType.Index = dtUnknown then + Result := 'CAST('+Result+' AS NVARCHAR('+IntToStr(SIZE_MB)+'))'; + end; + ngPgSQL: begin + if DataType.Index = dtUnknown then + Result := Result + '::text'; + end; + end; end;