Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-10

SQlite dataset small fix

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bogusław Brandys

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.

Regards
Boguslaw Brandys

Reply by email

Luiz Américo
to Bogusław Brandys
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

Reply by email

Luiz Américo
to Luiz Américo
Luiz Américo wrote
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.

If you don´t want to wait, see item 13 of the sqlite

Luiz

Reply by email