I'm building a data loader utility application (Win 7 64bit, VS 2008, C#, .Net 3.5, Win Forms) using Subsonic 2.2.
I've gotten everything working using SqlServer and now I need to get it working in Sqlite 3. I've worked through some issues but there is one I cannot resolve;
I have 2 columns, Latitude and Longitude that are FLOAT data types in sqlite and Subsonic generates as nullable floats. The code generation is fine, building is fine but when I attempt to run the application, when the object gets saved I get en error, "Can't save: Longitude exceeds the maximum length of 8."
My guess is that it's a verification issue in Subsonic as my Sqlite db has now issue with the data I have been loading into those columns.
Any Subsonic or Sqlite veterans out there have any suggestions, I am brand new to Subsonic and have only been working with Sqlite for about 6 months now.
Thanks,
Geoff
The value that is causing the error is -122.41082 which is over 8 chars but I don't think that's the limit for a float in sqlite. Maybe I'm choosing poorly when it comes to data types?
Best Answer
This is a SQLite issue as, from what I understand, SQLite doesn't have a concept of "types" - only inferences on values:
http://www.sqlite.org/faq.html#q3 How to ALTER sqlite column (iPhone)?
What I'm guessing here is that the inference is getting lost on the float translation - if you read up the docs, it says as much:
So it looks like the value you're passing in is NOT able to be stored as REAL (for some reason) and is trying to be tweaked to TEXT, with the limitation of a length of 8. This makes sense also because it's counting the decimal place - and it shouldn't (it only would if it's text).
Have a read here: http://www.sqlite.org/datatype3.html#affinity
It looks like this is the issue you're dealing with. All in all, SQLite is a "ducktyped" database, and many people have been bitten by it.
So, in short, I think your answer is probably to use Math.Round(3) to bring the value in under 8 total numbers + decimal (and the negative symbol) so it can be coerced into the column.