This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do_sqlite3 expects :database and :path options to be Strings
Once do_sqlite3 accepts both a Pathname or a String, normalizing the database and path won't be necessary anymore [#1324 state_resolved]
- Loading branch information
1 parent
2a8562b
commit 528fe37
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
528fe37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the 'database' key is a string, this code does not remove the key from the Hash. The options the Hash will contain { :database => db, 'database' => maybe_a_path } among other key/value pairs. When :database and 'database' are passed in as keys to do_sqlite3, I wonder which one will win?
Perhaps the code should become something like:
528fe37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for catching this Dan! Fixed in http://github.com/datamapper/dm-sqlite-adapter/commit/3e90a58e933c07235a56a9d85b1dc94efe7844cb
528fe37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snusnu: great! another option might be to transform the incoming Hash into a Mash (HashWithIndifferentAccess in AS), which might be a better long-term approach because this sort of thing could creep up in the future.
I'm also kind of anal about this, but I tend to do things like check for the presence of the key before doing anything, so I might even consider something like: (assuming that options is a Mash)
528fe37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am all for converting the Hash given to DataMapper into a Mash. When I first wrote the patch I was unsure whether DataMapper was normalizing the Hash, or if it expected the calling-library or Rails to handle that.