| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
Document the internal interfaces of `ConnectionSpecification::Resolver`
Change method name from `config` to `env` to better match the most common use case.
|
| |
|
|
|
| |
Building on the work of #13427 this PR adds a helpful error message to the adapters: mysql, mysql2, and sqlite3
|
| |
|
| |
|
| |
|
|\
| |
| | |
Do not store production information in .yml files
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code uses these checks in several places to know what to do with a
particular column, for instance AR attribute query methods has a branch
like this:
if column.number?
!value.zero?
end
This should never be true for array columns, since it would be the same
as running [].zero?, which results in a NoMethodError exception.
Fixing this by ensuring that array columns in PostgreSQL never return
true for number?/text? checks.
Since most of the array support was based on the postgres_ext lib, it's
worth noting it does the same thing for numeric array columns too:
https://github.com/dockyard/postgres_ext/blob/v1.0.0/lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb#L72
This extended the same logic for text columns to ensure consistency.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently if you attempt to use a database that does not exist you get an error:
```
PG::ConnectionBad FATAL: database "db_error" does not exist
```
The solution is easy, create and migrate your database however new developers may not know these commands by memory. Instead of requiring the developer to search for a solution, tell them how to fix the problem in the error message:
```
ActiveRecord::NoDatabase: FATAL: database "db_error" does not exist
Run `$ bin/rake db:create db:migrate` to create your database
```
Active Record should not know about `rake db:migrate` so this additional information needs to come from the railtie. Potential alternative implementation suggestions are welcome.
|
|
|
|
| |
Closes #13444
|
| |
|
|
|
|
|
| |
Need to check if valud also respond_to :id before calling it, otherwise
things could explode.
|
|\ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously, executing an insert SQL in PostgreSQL with a command like this:
insert into articles(
number)
values(
5152
)
would not work because the adapter was unable to extract the correct articles table name.
|
| |
| |
| |
| | |
Blast from the past, MySQL 4 era, when the password hashing style changed.
|
| | |
|
| |
| |
| |
| |
| | |
also override drop_table in AbstractMySQLAdapter to properly drop
temporary tables without committing the transaction
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This will fix the [broken
test](https://github.com/rails/rails/commit/4a2650836680f51490e999c3c8441a2f9adff96e)
`test_with_limiting_with_custom_select`.
The query's result was built in a hash with column name as key, if the
result have a duplicated column name the last value was
overriding the first one.
|
|\ \
| | |
| | | |
Translate new unique constraint error message for sqlite >= 3.8.2
|
| | | |
|
| | |
| | |
| | |
| | | |
Since MySQL 5.7.3 m13 does now allow primary key column is null.
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Closes #13146.
This fixes an error when using:
```
change_colum :table, :column, :bigint, array: true
```
|
| | |
| | |
| | |
| | |
| | |
| | | |
already have cache true.
This commit takes into account the last cache_enabled value, before clearing query_cache.
|
|\ \ \
| | | |
| | | | |
Typo fixes [ci skip]
|
| | | | |
|
|/ / /
| | |
| | |
| | |
| | | |
This method is not using the block variable directly since it is calling
yield
|
|\ \ \
| | | |
| | | | |
Remove `DatabaseStatements#case_sensitive_equality_operator`. It has been deprecated already.
|
| | | |
| | | |
| | | |
| | | | |
deprecated already.
|
|\ \ \ \
| |/ / /
|/| | | |
#type_cast - improve performance & readability
|
| | |/
| |/| |
|
| | |
| | |
| | |
| | | |
also clarify native rename_index support is >= 5.7, not > 5.7
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This prevents the following error when a MySQL index on a foreign key
column is renamed:
```
ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint: DROP INDEX `index_engines_on_car_id` ON `engines`
```
refs: #13038.
|
| | |
|
|\ \
| | |
| | |
| | |
| | | |
dougbarth/dont_swallow_exceptions_during_transactional_statements_in_mysql
Don't swallow exceptions in transctional statements
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The MySQL connection adapater swallows all StandardError exceptions,
which includes Mysql::Error and Mysql2::Error. The comment in the
exception clause claims errors thrown here indicate that transactions
aren't supported by the server but that isn't necessarily true. It's
possible the MySQL server has gone away and swallowing a failed commit
may let the application return a successful response when the data has
not been saved. Also, replication libraries like Galera require that the
application handle exceptions thrown at BEGIN/COMMIT.
I'm unable to determine what version of MySQL threw an exception for
transactional statements. I tried as far back as 3.23.49 with InnoDB
disabled but BEGIN & COMMIT statements do not throw an error. If there's
a real case for this logic to continue, we could instead push this
behavior into a configuration setting.
The exception swallowing has been there since the beginning:
db045dbbf60b53dbe013ef25554fd013baf88134
|
|\ \ \
| | | |
| | | | |
Move `SchemaCreation` to its own file instead of `AbstractAdapter`.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | | |
This has returned true since 3cc9b5f1, and is not used internally.
|
| | | |
| | | |
| | | | |
Drop some comments that document the implementation rather than the interface.
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|