#345 ✓resolved
Postmodern

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages