
Sqlite3Adapter#normalize_uri mangles absolute paths
Reported by Postmodern | June 5th, 2008 @ 12:21 AM
The normalize_uri method in Sqlite3Adapter will mangle absolute paths if they do not exist, essentially merging them with Dir.pwd.
normalize_uri should, ideally, only mangle relative paths. But the common sqlite3 URI syntax cannot specify relative paths.
Addressable::URI.parse("sqlite3:///path/to/db").path
# => "/path/to/db"
This is partly the reason why normalize_uri doesn't discriminate whether a path is relative or absolute. But I discovered an alternate Addressable::URI syntax.
Addressable::URI.parse("sqlite:relative/path/to/db").path
# => "relative/path/to/db"
This is how sqlite3::memory: is possible. This URI syntax should be used for merb web-apps that require a database file to be relative to the project directory. While sqlite3:///path syntax should be used in utilities that require an absolute path for their sqlite3 database (usually somewhere within ENV['HOME']).
Attached are a patch that reduces normalize_uri's mangling powers, and a patch to spec/integration/sqlite3_adapter_spec.rb so that both relative and absolute paths are tested with Sqlite3Adapter.
Comments and changes to this ticket
-
Dan Kubb (dkubb) June 5th, 2008 @ 01:24 AM
- State changed from new to open
Sam, can you give Postmodern commit access to dm-core to apply these patches? They look fine to me.
Postmodern, can you reply to this ticket with your github username?
-
-
Sam Smoot June 5th, 2008 @ 10:45 AM
Done. You have access to all 5 projects now. (dm-core, dm-more, dm-www, do, extlib).
-
Dan Kubb (dkubb) June 8th, 2008 @ 06:33 PM
- Milestone cleared.
Is this issue resolved? I thought I heard some grumblings about using File.expand_path from people on IRC.
Ideally I'd actually prefer to pass through as much of the configuration to SQLite3 as possible. It seems like the safest approach, rather than trying to make all relative paths to the DB files absolute and then handing that to SQLite3.
-
Postmodern June 9th, 2008 @ 01:15 AM
- no changes were found...
-
Postmodern June 9th, 2008 @ 01:15 AM
- no changes were found...
-
Postmodern June 9th, 2008 @ 02:13 AM
- no changes were found...
-
Dan Kubb (dkubb) June 9th, 2008 @ 01:09 PM
Postmodern, this looks pretty good. Do you mind applying and pushing this?
-
Dan Kubb (dkubb) December 2nd, 2008 @ 03:46 AM
- Tag set to fix, normalize_uri, spec, sqlite3
- Milestone cleared.
- State changed from open to hold
- Assigned user cleared.
Postmodern, is this still valid or can I close this ticket?
-
Postmodern December 4th, 2008 @ 04:55 AM
I would say this ticket has been resolved. The offending method which attempted to normalize sqlite3 URIs has since been removed. I guess the real issue is there needs to be more examples of DataMapper URI usage.
-
Dan Kubb (dkubb) December 4th, 2008 @ 02:27 PM
- State changed from hold to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »