-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite Provider InvalidCastException #578
Comments
I seem to have resolved this with a change to the LoadSql method to cast the 2 columns DurationMilliseconds and StartMilliseconds to REAL
Which based on https://stackoverflow.com/questions/39980840/sqlite-using-dapper-error-parsing-column-unable-to-cast-object-of-type-system is a known problem. I don't fully understand why |
Is there a work around for this? |
@bricelam Could you chime in on this one please? Any downside to changing to REAL you're aware of? |
Is it possible to call If you're OK with precision loss, using REAL for the column type is acceptable. This causes the database to cast the values (from 128-bit floating-point TEXT values to 64-bit floating-point REAL values) when the values are inserted. Alternatively, you could cast the NUMERIC doesn't work because it only casts the value if it can do so without precision loss. |
Wait, I may not have the full picture... lol, is |
Ah, I think I see now. Yes, the column type Calling DbDataReader.GetValue (or using the indexer) will let the values determine their own types. All of this leads to I strongly encourage users to only ever use TEXT, INTEGER, REAL and BLOB as column types. There are a handful of awful cases just like this if you don't. (The worst being STRING casting to INTEGER if it can.) |
It's also worth noting that precision, scale, and length on column types have no effect on SQLite. |
Is my change ok to be accepted? |
I also ran into this one today, would be great to get the PR merged |
Fix for #578 Changed all DECIMAL columns to REAL to avoid an issue with dynamic datatypes in sqlite as discussed in https://stackoverflow.com/questions/39980840/sqlite-using-dapper-error-parsing-column-unable-to-cast-object-of-type-system
I happen to be working on this after a long break just this week - this will be in a 4.3 release soon :) |
Going to close this our since #582 is merged in - look out for a 4.3 release on NuGet soon, but already on MyGet now :) |
When using the Sqlite Provider i encountered the following error.
This is similar to the final message in the PR #221
It seems to stem from the dynamic datatypes of Sqlite.
The text was updated successfully, but these errors were encountered: