Open radekm opened 10 months ago
Hello, it seems that System.Int64
for Alive is the issue. I need to check the SQLite docs, but isn't there a more suitable type for boolean value than INT
?
Documentation https://www.sqlite.org/datatype3.html recommends INT:
2.1. Boolean Datatype
SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).
SQLite recognizes the keywords "TRUE" and "FALSE", as of version 3.23.0 (2018-04-02) but those keywords are really just alternative spellings for the integer literals 1 and 0 respectively.
Hmm, seems that using BOOLEAN in schema definition works. Now REAL
can't be converted to decimal only to float...
So following works without CLIMutable
(still it would be nice to have Salary : decimal
):
type Person = { Name : string
Salary : string
Alive : bool }
let createScript = """
CREATE TABLE IF NOT EXISTS "Person" (
"Name" TEXT NOT NULL,
"Salary" TEXT NOT NULL,
"Alive" BOOLEAN NOT NULL,
PRIMARY KEY("Name")
);
"""
Just wanted to jump in and say this also happens on MSSQL. In my case i'm using bool on the source table as well. I can provide more details if it helps, but they're very wide tables so it's hard to narrow down what's really causing the issue. Adding CLIMutable fixed it though.
According to
README.md
and already closed issue https://github.com/Dzoukr/Dapper.FSharp/issues/67 adding[<CLIMutable>]
to F# records isn't necessary.But when I run the following code without
[<CLIMutable>]
I get the following exception
Adding
[<CLIMutable>]
solves the problem. Also changing the recordPerson
tosolves the problem but that is not what I want because it defeats the point of adding type handlers. I'm using following libraries:
So my question is whether there's a mistake in my code or
[<CLIMutable>]
needs to be used with certain records?Maybe it has something to do with SQLite which doesn't have dedicated type for bool or for decimal?