1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

20 commits

Author SHA1 Message Date
Matthew Draper
0a99fddc14 Complete change of sqlite3:/// path handling
That which was now relative is now absolute.
2014-04-03 01:41:34 +10:30
Matthew Draper
f846828dae Revise 'sqlite3:' URL handling for smoother upgrades
Restore the 4.0 behaviour for 'sqlite3:///', but deprecate it. We'll
change to the absolute-path interpretation in 4.2.

The current "correct" spellings for in-memory, relative, and absolute
URLs, respectively, are:

    sqlite3::memory:
    sqlite3:relative/path
    sqlite3:/full/path

Substantially reverses/defers fbb79b517f.
Uncovered by @guilleiguaran while investigating #14495, though that
sounds like a different issue.
2014-04-03 01:30:27 +10:30
schneems
5b96027ef6 Allow "url" sub key in database.yml configuration
Currently a developer can pass in a YAML configuration that fully specifies connection information:

```
production:
  database: triage_production
  adapter: password
  pool: 5
```

They can also pass in a string that specifies a connection URL directly to an environment key:

```
production: postgresql://localhost/foo
```

This PR allows the use of both a connection url and specifying connection attributes via YAML through the use of the "url" sub key:

```
production:
  url: postgresql://localhost/foo
  pool: 3
```

This will allow developers to inherit Active Record options such as `pool` from `&defaults` and still use a secure connection url such as `<%= ENV['DATABASE_URL'] %>`. The URL is expanded into a hash and then merged back into the YAML hash. If there are any conflicts, the values from the connection URL are preferred. 

Talked this over with @josevalim
2013-12-30 12:21:14 -05:00
José Valim
d2ed433b0a Only build a ConnectionSpecification if required 2013-12-24 10:02:07 +01:00
José Valim
c390e60811 Guarantee the connection resolver handles string values
This commit also cleans up the rake tasks that were checking
for DATABASE_URL in different places.

In fact, it would be nice to deprecate DATABASE_URL usage in the long
term, considering the direction we are moving of allowing those in .yml
files.
2013-12-23 20:15:52 +01:00
Kuldeep Aggarwal
34f17b871e added test cases for Resolver#connection_url_to_hash 2013-12-23 16:45:00 +05:30
Rafael Mendonça França
e54acf1308 Do not type cast all the database url values.
We should only type cast when we need to use.

Related to 4b005fb371
2013-02-24 14:36:18 -03:00
Rafael Mendonça França
e1456ad95e Whitespace ❤️ and hash syntax change 2013-02-20 10:27:18 -03:00
Yves Senn
0a6b61a5f5 descriptive error message when AR adapter was not found. Closes #7313. 2013-02-20 10:54:58 +01:00
Aaron Stone
4b005fb371 DATABASE_URL parsing should turn numeric strings into numeric types, and
the strings true and false into boolean types, in order to match how
YAML would parse the same values from database.yml and prevent
unexpected type errors in the database adapters.
2013-01-31 09:01:20 -08:00
Rafael Mendonça França
bb38df89bf Standardize the use of current_adapter? 2013-01-01 19:18:34 -03:00
Rafael Mendonça França
81679ab2ae Fix the skip code.
Checking for the constant doesn't work
2012-10-28 23:48:34 -02:00
Shawn Veader
f96b410bc7 Decode attributes pulled from URI.parse
The RFC indicates that username and passwords may be encoded.
http://tools.ietf.org/html/rfc2396#section-3.2.2

Found this trying to use the mysql://username:password@host:port/db and having special characters in the password which needed to be URI encoded.
2012-10-26 15:43:07 -04:00
Grace Liu
148c50b49a fixed support for DATABASE_URL for rake db tasks
- added tests to confirm establish_connection uses DATABASE_URL and
  Rails.env correctly even when no arguments are passed in.
- updated rake db tasks to support DATABASE_URL, and added tests to
  confirm correct behavior for these rake tasks.  (Removed
  establish_connection call from some tasks since in those cases
  the :environment task already made sure the function would be called)
- updated Resolver so that when it resolves the database url, it
  removes hash values with empty strings from the config spec (e.g.
  to support connection to postgresql when no username is specified).
2012-09-11 20:40:13 -07:00
David Paschich
a36bda8770 The resolver tests fail if the mysql gem is not installed; this breaks
being able to run the sqlite3 tests without that gem. This fix ensures
the tests will only run if the mysql gem is installed.

A better solution might be to move these tests into the per-adapter tests,
and test each adapter's resolver.
2012-06-03 17:24:17 -07:00
Jon Leighton
dae7b65453 Support establishing connection on ActiveRecord::Model.
This is the 'top level' connection, inherited by any models that include
ActiveRecord::Model or inherit from ActiveRecord::Base.
2011-12-28 18:27:41 +00:00
Jon Leighton
6af7192af5 I herd you like modules. 2011-12-24 11:08:15 +00:00
Aaron Patterson
f73f53455a respond_to? information of AR is not the responsibility of the spec
resolver.
2011-11-29 11:48:55 -08:00
Jon Leighton
d534c8fbe2 Fix resolver_test.rb on travis (postgresql isn't setup, so it can't load the connection adapter) 2011-11-29 12:47:54 +00:00
Aaron Patterson
dde2113867 Move connection resoluion logic to it's own testable class. 2011-11-28 15:23:25 -08:00