datamapper / do

DataObjects
147 stars 73 forks source link

In reference to issue #276 on dm-core - untested #87

Closed boazsegev closed 8 years ago

boazsegev commented 9 years ago

in this issue "Booleans are always stored as false in SQLite", FeeJai stated that:

With the SQLite adapter, Booleans are transformed to 't' and 'f' in the queries. These string values are typecasted to false by sqlite. So datamapper persists the wrong values.

I have no idea if this statement is correct, it could be a specific installation or environment issue that only applies to FeeJai... I'm just forwarding his request for a fix and fulfilling his request that I try and help.

This proposed pull request is a GUESS about the source of the issue (assuming it isn't an issue with FeeJai's specific environment), I can't test it on my machine.

Please have a look.

dbussink commented 8 years ago

First of all thanks for the contribution, but I'm going to have to reject it. SQLite has no concept of a boolean type, so the only way is to pick a convention. Right now that convention is a t or f. The quotes removed here are not the right approach, since the explicit goal of this method is to return a quoted string. As you can also see in the tests, this breaks the designed behavior.

There are tests that verify that a t comes back as boolean so the problem is not likely to be inside DO. The problem in https://github.com/datamapper/dm-core/issues/276 is likely somewhere in DataMapper, but it's hard to identify it without a script that reproduces the problem.

boazsegev commented 8 years ago

Thanks for the detailed response and for taking the time to review the issue.

I hope someone manages to track down the issue, as DM is a great library.