aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/connection_specification.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated access to connection specification using a string acessor.Rafael Mendonça França2015-01-041-20/+1
| | | | Now all strings will be handled as a URL.
* Wrap code snippets in +, not backticks, in sdocclaudiob2014-11-201-1/+1
| | | | | | | | I grepped the source code for code snippets wrapped in backticks in the comments and replaced the backticks with plus signs so they are correctly displayed in the Rails documentation. [ci skip]
* edit pass over all warningsXavier Noria2014-10-281-1/+1
| | | | | | | | | | | | | | | This patch uniformizes warning messages. I used the most common style already present in the code base: * Capitalize the first word. * End the message with a full stop. * "Rails 5" instead of "Rails 5.0". * Backticks for method names and inline code. Also, converted a few long strings into the new heredoc convention.
* let's warn with heredocsXavier Noria2014-10-281-2/+7
| | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* use tr instead of gsub when possibleAdrian Rangel2014-10-011-1/+1
|
* use the uri parser so that newer version of Ruby workAaron Patterson2014-08-071-1/+1
|
* Fix documentation typo in ConnectionSpecification::Resolve.speca3gis2014-07-241-1/+1
|
* Fixes #16265a3gis2014-07-241-1/+1
|
* Parsing DATABASE_URI, use URI#hostname: it's smarter about IPv6Matthew Draper2014-06-141-1/+1
| | | | Fixes #15705.
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2014-04-181-2/+2
|\
| * [ci skip] Use valid current config in exampleschneems2014-04-151-2/+2
| | | | | | `reaping_frequency` is used in Active Record `reap_frequency` is not
* | Drop in @jeremy's new database.yml template textMatthew Draper2014-04-091-1/+1
| | | | | | | | | | In passing, allow multi-word adapters to be referenced in a URL: underscored_name must become hyphened-name.
* | Give a deprecation message even when the lookup failsMatthew Draper2014-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | If the supplied string doesn't contain a colon, it clearly cannot be a database URL. They must have intended to do a key lookup, so even though it failed, give the explanatory deprecation warning, and raise the exception that lists the known configs. Conveniently, this also simplifies our logical behaviour: if the string matches a known configuration, or doesn't contain a colon (and is therefore clearly not a URL), then we output a deprecation warning, and behave exactly as we would if it were a symbol.
* | Merge pull request #14569 from matthewd/sqlite_relative_deprecatedRafael Mendonça França2014-04-031-17/+30
|\ \ | | | | | | | | | | | | | | | | | | Revise 'sqlite3:' URL handling for smoother upgrades Conflicts: activerecord/CHANGELOG.md
| * | Complete change of `sqlite3:///` path handlingMatthew Draper2014-04-031-15/+1
| | | | | | | | | | | | That which was now relative is now absolute.
| * | Revise 'sqlite3:' URL handling for smoother upgradesMatthew Draper2014-04-031-18/+45
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 fbb79b517f3127ba620fedd01849f9628b78d6ce. Uncovered by @guilleiguaran while investigating #14495, though that sounds like a different issue.
* | Avoid including DB details in exception messagesMatthew Draper2014-04-031-1/+1
| | | | | | | | | | The keys are quite sufficient; we shouldn't be throwing passwords around.
* | Avoid a spurious deprecation warning for database URLsMatthew Draper2014-04-031-23/+27
|/ | | | | | | | | | | | | | | | | | This is all about the case where we have a `DATABASE_URL`, and we have a `database.yml` present, but the latter doesn't contain the key we're looking for. If the key is a symbol, we'll always connect to `DATABASE_URL`, per the new behaviour in 283a2edec2f8ccdf90fb58025608f02a63948fa0. If the key is a string, on the other hand, it should always be a URL: the ability to specify a name not present in `database.yml` is new in this version of Rails, and that ability does not stretch to the deprecated use of a string in place of a symbol. Uncovered by @guilleiguaran while investigating #14495 -- this actually may be related to the original report, but we don't have enough info to confirm.
* Allow custom JDBC urlsschneems2014-03-141-2/+2
| | | | mitigates #14323
* Ensure Active Record connection consistencyschneems2014-01-091-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently Active Record can be configured via the environment variable `DATABASE_URL` or by manually injecting a hash of values which is what Rails does, reading in `database.yml` and setting Active Record appropriately. Active Record expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot rip out this functionality without deprecating. This presents a problem though when both config is set, and a `DATABASE_URL` is present. Currently the `DATABASE_URL` should "win" and none of the values in `database.yml` are used. This is somewhat unexpected to me if I were to set values such as `pool` in the `production:` group of `database.yml` they are ignored. There are many ways that active record initiates a connection today: - Stand Alone (without rails) - `rake db:<tasks>` - ActiveRecord.establish_connection - With Rails - `rake db:<tasks>` - `rails <server> | <console>` - `rails dbconsole` We should make all of these behave exactly the same way. The best way to do this is to put all of this logic in one place so it is guaranteed to be used. Here is my prosed matrix of how this behavior should work: ``` No database.yml No DATABASE_URL => Error ``` ``` database.yml present No DATABASE_URL => Use database.yml configuration ``` ``` No database.yml DATABASE_URL present => use DATABASE_URL configuration ``` ``` database.yml present DATABASE_URL present => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url` sub key "wins". If other paramaters `adapter` or `database` are specified in YAML, they are discarded as the `url` sub key "wins". ``` ### Implementation Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge all connection information before returning. This is achieved through a utility class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`. To understand the exact behavior of this class, it is best to review the behavior in activerecord/test/cases/connection_adapters/connection_handler_test.rb though it should match the above proposal.
* Fix AR connection resolver docs to return a hash with string keys [ci skip]Carlos Antonio da Silva2014-01-061-1/+1
|
* Fix typo [ci skip]Carlos Antonio da Silva2014-01-061-1/+1
|
* Allow "url" sub key in database.yml configurationschneems2013-12-301-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ci skip] ConnectionSpecification::Resolver Docsschneems2013-12-301-14/+80
| | | | | Document the internal interfaces of `ConnectionSpecification::Resolver` Change method name from `config` to `env` to better match the most common use case.
* Extract db url connection logic to classschneems2013-12-291-34/+79
|
* Deprecate use of string in establish_connection as connection lookupJosé Valim2013-12-241-9/+16
|
* Only build a ConnectionSpecification if requiredJosé Valim2013-12-241-26/+28
|
* Fix build failures related to the new ENV options in ymlJosé Valim2013-12-241-3/+3
|
* Guarantee the connection resolver handles string valuesJosé Valim2013-12-231-20/+29
| | | | | | | | | 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.
* fix url connections for sqlite3Aaron Patterson2013-12-201-1/+12
|
* Add a note about ensuring the version is right for the adapter (since you ↵David Heinemeier Hansson2013-10-271-1/+1
| | | | might well have specified the right gem, but locked it to too low of a version)
* Remove hard coded references to Active Record in railtiesJosé Valim2013-03-021-2/+2
|
* Do not type cast all the database url values.Rafael Mendonça França2013-02-241-21/+0
| | | | | | We should only type cast when we need to use. Related to 4b005fb371c2e7af80df7da63be94509b1db038c
* make type_cast_value a class level methodTerence Lee2013-02-211-1/+1
|
* standardize database_configuration to a hashTerence Lee2013-02-211-2/+2
| | | | | | | make connection_url_to_hash a class method This als prevents loading database.yml if it doesn't exist but DATABASE_URL does
* descriptive error message when AR adapter was not found. Closes #7313.Yves Senn2013-02-201-2/+5
|
* Fix typo :bomb:Rafael Mendonça França2013-01-311-1/+1
|
* Strict regexpRafael Mendonça França2013-01-311-2/+2
|
* Extract the value casting to a methodRafael Mendonça França2013-01-311-15/+23
|
* DATABASE_URL parsing should turn numeric strings into numeric types, andAaron Stone2013-01-311-0/+19
| | | | | | 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.
* Decode attributes pulled from URI.parseShawn Veader2012-10-261-0/+2
| | | | | | | 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.
* fixed support for DATABASE_URL for rake db tasksGrace Liu2012-09-111-1/+1
| | | | | | | | | | | | - 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).
* Require URIChris Bandy2012-06-281-0/+2
|
* connection specification will deep copy the configAaron Patterson2011-12-301-0/+4
|
* each connection pool has a reaperAaron Patterson2011-12-301-1/+1
|
* Support establishing connection on ActiveRecord::Model.Jon Leighton2011-12-281-0/+79
This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base.