Search code examples
sqlitef#type-providers

F# SQLProvider SQLite ignored columns types


The type provider doesn't seem to add all data types to the list of available types : integer and text work fine for instance, but varchar or int with specified length are ignored (while VARCHAR with no length specification works fine).

Is this "normal" (is there a setting to modify) ? (It seems Mysql sql scripts include varchar size limitations for instance)

#r @"..\packages\SQLProvider.1.0.37\lib\FSharp.Data.SqlProvider.dll"

open FSharp.Data.Sql

let [<Literal>] resolutionPath = __SOURCE_DIRECTORY__ + @"\..\packages\System.Data.SQLite.Core.1.0.103\lib\net45" 
let [<Literal>] connectionString = "Data Source=" + __SOURCE_DIRECTORY__ + @"\northwindEF.db; Version=3; foreign keys=true"
// create a type alias with the connection string and database vendor settings
type sql = SqlDataProvider< 
              ConnectionString = connectionString,
              DatabaseVendor = Common.DatabaseProviderTypes.SQLITE,
              SQLiteLibrary = Common.SQLiteLibrary.AutoSelect,
              ResolutionPath = resolutionPath,
              IndividualsAmount = 1000,
              UseOptionTypes = true, 
              CaseSensitivityChange = Common.CaseSensitivityChange.ORIGINAL>
let db = sql.GetDataContext()

for x in db.Main.Country do
  printfn "%A" x. //columns are ignored depending on their type

My country table has the following structure :

CREATE TABLE country (
    id            INTEGER       PRIMARY KEY AUTOINCREMENT
                                NOT NULL,
    name          VARCHAR (255) NOT NULL,
    area_id       INTEGER,
    local_currency_id   INTEGER,
    comments      TEXT,
    numeric_code  INTEGER (3)   UNIQUE,
    alpha2_code   VARCHAR (2)   UNIQUE,
    alpha3_code   VARCHAR (3)   UNIQUE,
    svg_data_url  TEXT
);

Solution

  • It seems it comes from the SQLite type provider code where a space between varchar and (255) prevents the mapping lookup.

    I have got in touch with the code maintainers.