Bogusław Brandys wrote 10 lines
Hello,
Attached diff for sqliteds.pas and sqlite3ds.pas allow to properly
recognize CHAR(X) and VARCHAR(X) types for sqlite dataset.
It is really small fix done because I have such sqlite database with
defined VARCHAR fields (although sqlite is typeless)
It is using Pos function to find if CHAR is somewhere inside field type
and to find () and get X value .Maybe not too clever but I could'nt find
any better/simpler way.
A better/simpler way would be to treat any field declaration that doesn't fit in the hardcoded ones as a String (VARCHAR) field.
Until fpc 2.0.0 version, TSqliteDataset used this aproach. This allowed to use sqlite databases created outside TSqliteDataset. The drawback is that the user would expect that a "NUM" field be treated as a Integer or a Float when it would not. So, to avoid this situation, if a field type declaration is not recognized an error is throw and the dataset is not opened.
The solution is to migrate the datafile to the table layout used by TSqliteDataset programatically. I'll do routine/program that does it, if you want please give a week. I'll post the code in the fpc list.
As the TSqliteDataset maintainer i'm against this change, but the final decision is to the RTL developers, most notable Michael Van Canneyt
PS:
- FieldSize in String fields should always be 0 - I will fix it later
- Also note that sqlite treats CHAR()/VARCHAR[()]/Whatever the same way.
Luiz