and check what's returned for FD, FT and TStorageType
Well, that's not so difficult.
In my testprogram FT is only ftUnknown for the CAST/FUNCTION/calculated field.
FN does have a name (lol).
FD is empty.
And sqlite3_column_type(st,i) of course results in stText (otherwise you wouldn't get the problematic ftMemo now).
So, because FD is empty, sqlite3_column_decltype somehow doesn't get the correct datatype of that field.
Then the type is guessed via sqlite3_column_type.
Normally, when that's stText, you just use ftString (TStringField).
// In case of an empty fieldtype (FD='', which is allowed and used in calculated
// columns (aggregates) and by pragma-statements) or an unknown fieldtype,
// use the field's affinity:
Why was the decision made to use ftMemo for calculated fieds (like CONCAT/COALESCE/CAST etc) ???
stText fields have no problems being larger than 1020.
But I don't work with FTS tables.
Can you provide a simular smal example project where you encountered that problem?
Above is point 1. The wrongly translating calculated fields from stText to ftMemo.
Point 2 is... when you do use the override for OnGetText... why does TDBLookupComboBox not use that text.
(I'll need to dive into that one)
Edit: O, WOW. Point 1 even gets more problematic.
If I use this for table creation
CREATE TABLE master(id INT, lol text);
So I use the native TEXT from SQLite... then all those fields also show (MEMO).
For VARCHAR(25) this was not the case.
But it seems that native TEXT is always routed to ftMemo (see FieldMap).
So maybe the calculated fields should be too.
But how to force them to ftString when you use CAST as VARCHAR?
BTW. standard using VARCHAR without specifying length in SQLite, FPC cuts the field to 1020.
Although the fields itself in SQLite does contain the original length.
So somewhere, there is a limit in FPC when no length is specified.
This might also be the case for the FTS tables.