From 858e8a3b4afdab9b0c387d8aebdadc4e5a8db116 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 2 Feb 2020 16:03:39 +0100 Subject: [PATCH] Detect column default value as text if it starts with a single quote. Applies to older MySQL versions without IS.columns. Closes #873 --- source/dbconnection.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index c9cbdb4e..a912567a 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -4663,8 +4663,12 @@ begin Col.DefaultType := cdtAutoInc; Col.DefaultText := 'AUTO_INCREMENT'; end else if ColQuery.IsNull('Default') then begin - Col.DefaultType := cdtNull; - end else if Col.DataType.Category in [dtcText, dtcBinary, dtcTemporal, dtcOther] then begin + Col.DefaultType := cdtNothing; + end else if DefText.StartsWith('''') then begin + Col.DefaultType := cdtText; + Col.DefaultText := ExtractLiteral(DefText, ''); + end else if DefText.IsEmpty or IsInt(DefText[1]) then begin + // Inexact detection, wrong if MySQL allows 0+1 as default value at some point Col.DefaultType := cdtText; Col.DefaultText := DefText; end else begin