01 August 2008

SQlite3::SQLException: SQL logic error or missing database

SQlite3 errors messages are not very clear ...

"SQlite3::SQLException: SQL logic error or missing database" when inserting should be translated by:
"Invalid id, there is alreay a record in the table with the same id"

In general, we waste a lot of time because libraries authors focus on the "successfull" cases and can't think of all the cases where things can go wrong ...

To play on the safe side, we could try to adopt a defensive programming style and start to write tests (specs) of things which can can fail ...

ActiveRecord find method is quite flexible

Every day, a new discovery about a Rails feature :-)

It sounds like the "find" methods is not too picky about its parameter, if given a string instead of an integer, it will the find the record anyway. I wonder if the author of this code knew about it ...

Event.find("7476-taranna")
=> #Event id: 7476, name: "TarannĂ ", place_id: 484, ...

Update:
After Marius' comment, I googled a bit and found a post by Obie Fernandez which explains the whole thing in details ...