Closed tforkmann closed 4 years ago
v2.0 has been released and includes reading functions that distinguish between existing values, nullables values and throws when the types are incorrect:
connectionString
|> Sql.connect
|> Sql.query "SELECT * FROM dbo.[Users]"
|> Sql.execute (fun read -> read.int "non_nullable_int", read.stringOrNone "nullable_string")
Would you give it a try and see if the problem gets resolved?
Also, now the library handles integers much better: if you try to read an integer of small size into a bigger size (say if column type is tinyint
and you read it as int
) then it is automatically converted.
Hi Zaid!
Thank you soo much! This works great now!
Testing the next issue now!
Is your feature request related to a problem? Please describe. I tried to read and Id and though the Id would be of the type tinyint. Somehow the query returned a empty array. Turned out the id as of the type int instead. I fiquered out it helps if you print out the unmatched case of the SqlValue.
Describe the solution you'd like
Before you just returned None as a result of the read value:
I added a little helper to print out the unmatched case:
This at least shows that there were some values and you just didn't picked the correct SqlValue type.