Commit Graph

75224 Commits

Author SHA1 Message Date
Tanbir Hasan 15365de5a4
Fix docs about etag 2019-12-10 15:55:16 +06:00
Richard Schneeman 32b363b246
Merge pull request #37738 from joshuaflanagan/allow_equals_in_db_url_query_value
Database URL supports query value with equal sign
2019-12-09 16:20:01 -06:00
Rafael França 2ab8364bde
Merge pull request #37916 from Edouard-chin/ec-fix-actionview-tag-option
Fix input value not properly applied:
2019-12-09 19:10:16 -03:00
Edouard CHIN 95bc8d0a23 Fix input value not properly applied:
- #37872 introduced a regression and you can't do

  ```html.erb
    hidden_field_tag('token', value: [1, 2, 3])
  ```

  This will result in a `<input type="hidden" value=""`>.

  I chose `hidden_field_tag` and the `value` attribute as an example
  but this issue applies to any tag helper and any attributes.

  https://github.com/rails/rails/pull/37872#issuecomment-561806468
  mention that the feature should only apply for "class" attribute.

  This commit fix original intent of #37872
2019-12-09 22:54:25 +01:00
Rafael Mendonça França 73e079a184
Merge pull request #35210 from pjrebsch/fix-joins-include-select
Retain selections with `includes` and `joins`
2019-12-09 15:28:46 -03:00
Joshua Flanagan 43a6420e17 Database URL supports query value with equal sign
A querystring value should be allowed to include an equal sign `=`.

This is necessary to support passing `options` for a PostgresSQL connection.

```

development:
  url: postgresql://localhost/railsdevapp_development?options=-cmysetting.debug=on
```

Before this PR, attempting to start the rails process with that configuration would result in an error:

```
> bundle exec rails console
Traceback (most recent call last):
	49: from bin/rails:4:in `<main>'
	48: from bin/rails:4:in `require'
...
	 1: from /rails/activerecord/lib/active_record/database_configurations/connection_url_resolver.rb:58:in `query_hash'
/rails/activerecord/lib/active_record/database_configurations/connection_url_resolver.rb:58:in `[]': invalid number of elements (3 for 1..2) (ArgumentError)
```

After this PR, rails can properly parse the configuration:

```
> bundle exec rails console
Loading development environment (Rails 6.1.0.alpha)
2.6.5 :001 > ActiveRecord::Base.connection.select_all("show mysetting.debug").to_a
   (0.4ms)  show mysetting.debug
 => [{"mysetting.debug"=>"on"}]
```
2019-12-09 12:11:58 -06:00
Rafael França b4ab1f19d8
Merge pull request #37798 from Edouard-chin/ec-sqlite3-connection-transaction
Added posibility to open a `read_uncommitted` transaction on SQLite:
2019-12-09 14:32:53 -03:00
Rafael França 9926fd8662
Merge pull request #37827 from Edouard-chin/ec-activejob-enqueuing
Don't run AJ after_enqueue / after_perform when chain is halted:
2019-12-09 13:50:48 -03:00
Edouard CHIN bbfab0b33a Don't run AJ after_enqueue / after_perform when chain is halted:
- ### Problem

  ```ruby
    MyJob < ApplicationJob
      before_enqueue { throw(:abort) }
      after_enqueue { # enters here }
    end
  ```
  I find AJ behaviour on after_enqueue and after_perform callbacks
  weird as they get run even when the callback chain is halted.
  It's counter intuitive to run the after_enqueue callbacks even
  though the job wasn't event enqueued.

  ### Solution

  In Rails 6.2, I propose to make the new behaviour the default
  and stop running after callbacks when the chain is halted.
  For application that wants this behaviour now or in 6.1
  they can do so by adding the `config.active_job.skip_after_callbacks_if_terminated = true`
  in their configuration file.
2019-12-09 17:17:23 +01:00
Rafael França 7f4d222c37
Merge pull request #37830 from Edouard-chin/ec-activejob-enqueue-and-perform-log
Fix ActiveJob logging when callback chain is halted:
2019-12-09 13:05:10 -03:00
Rafael Mendonça França c12814173f
Add myself of codeowner of the rubocop config 2019-12-09 12:42:06 -03:00
Edouard CHIN 0d3aec4969 Fix ActiveJob logging when callback chain is halted:
- ### Problem

  ActiveJob will always log "Enqueued MyJob (Job ID) ..." even
  if the job doesn't get enqueued through the adapter.
  Same problem happens when performing a Job, "Performed MyJob (Job ID) ..." will be logged even when job wasn't performed at all.
  This situation can happen either if the callback chain is terminated
  (before_enqueue throwing an `abort`) or if an exception is raised.

  ### Solution

  Check if the callback chain is aborted/exception is raised, and  log accordingly.
2019-12-09 16:17:55 +01:00
Rafael Mendonça França 737fb59eb3
Fix Rubocop violation 2019-12-09 12:14:24 -03:00
Edouard CHIN 82e767f3d3 Don't assume all database in SQLite are files:
- SQlite allow database to be specified as URL (given that URI filename
  interpretation was turned on on the connection.)

  This commit is necessary for the read_uncommitted transaction
  feature because SQLite doesn't allow to enable the shared-cache mode
  if the database name is `:memory:`. It has to be a URI (`file::memory`)

  Ref https://www.sqlite.org/sharedcache.html#shared_cache_and_in_memory_databases
2019-12-09 15:56:44 +01:00
Edouard CHIN cf5b6199df Added posibility to open a `read_uncommitted` transaction on SQLite:
- ### Use case

  I'd like to be able to see changes made by a connection writer
  within a connection reader before the writer transaction commits
  (aka `read_uncommitted` transaction isolation level).

  ```ruby
  conn1.transaction do
    Dog.create(name: 'Fido')
    conn2.transaction do
      Dog.find(name: 'Fido') # -> Can't see the dog untill conn1 commits the transaction
    end
  end
  ```

  Other adapters in Rails (mysql, postgres) already supports multiple
  types of isolated db transaction.
  SQLite doesn't support the 4 main ones but it supports
  `read_uncommitted` and `serializable` (the default one when opening
  a transaction)

  ### Solution

  This PR allow developers to open a `read_uncommitted` transaction by
  setting the PRAGMA `read_uncommitted` to true for the duration
  of the transaction. That PRAGMA can only be enabled if the SQLite
  connection was established with the [shared-cache mode](https://www.sqlite.org/sharedcache.html)

  This feature can also benefit the framework and we could potentially
  get rid of the `setup_shared_connection_pool` inside tests which
  was a solution in the context of a multi-db app so that the reader
  can see stuff from the open transaction writer but has some [caveats](https://github.com/rails/rails/issues/37765#event-2828609021).

  ### Edge case

  Shared-cache mode can be enabled for in memory database as well,
  however for backward compatibility reasons, SQLite only allows
  to set the shared-cache mode if the database name is a URI.
  It won't allow it if the database name is `:memory`; it has to be
  changed to `file::memory` instead.
2019-12-09 15:56:44 +01:00
Rafael Mendonça França e67fdc5aeb
Revert "Merge pull request #37504 from utilum/no_implicit_conversion_of_nil"
This reverts commit 4e105385d0, reversing
changes made to 62b4383909.

The change in Ruby that made those changes required was reverted in
8852fa8760
2019-12-09 11:50:39 -03:00
Rafael França 7c3e4409fd
Merge pull request #37913 from kirikiriyamama/merge-shared-configuration-deeply
Rails::Application#config_for merges shared configuration deeply
2019-12-09 11:04:47 -03:00
kirikiriyamama 2b17c114eb Add CHANGELOG entry for 4d858b3f2a 2019-12-09 15:20:27 +09:00
kirikiriyamama 4d858b3f2a Merge shared configuration deeply 2019-12-08 22:18:08 +09:00
Dalto Curvelano b4ee2d5f65 Update documentation for setting up database tests (#37475)
[ci skip]
2019-12-08 11:06:35 +09:00
finn 9024fa31e2 update getting_started guide to reduce confusion [ci skip] (#37750)
Add a yellow "NOTE" block to see if the guide looks better.
2019-12-08 09:25:49 +09:00
Shu Fujita 97b0833458 Update docs of String methods using ActiveSupport::Inflector [ci skip] (#37890) 2019-12-07 12:11:15 +09:00
Peter Zhu d0dd199206 Make sure variant is created on the same service 2019-12-06 22:02:07 -05:00
Gannon McGibbon 352445b2b6
Merge pull request #37904 from peterzhu2118/as-remove-query-params
Remove unused query params in DiskService
2019-12-06 18:40:12 -05:00
Peter Zhu 2e15092942 Remove query params in DiskService 2019-12-06 16:52:30 -05:00
Gannon McGibbon 8cf3f9ad23
Merge pull request #37897 from peterzhu2118/as-public-disk-blob-fixes
Use DiskController for both public and private files
2019-12-06 16:41:37 -05:00
Peter Zhu fbb83d78c3 Use DiskController for both public and private files 2019-12-06 16:02:16 -05:00
George Claghorn 2963a30cf9 Go through ActiveStorage::Blob::Representable#variant to pick up tracking 2019-12-06 14:20:38 -05:00
George Claghorn f7da355409 Add resolved route for ActiveStorage::VariantWithRecord 2019-12-06 14:03:07 -05:00
George Claghorn c9502a33a1 Correct migration name 2019-12-06 13:30:58 -05:00
George Claghorn 7d0327bbbf Track Active Storage variants in the database 2019-12-06 13:26:51 -05:00
Rafael França 758e4f8406
Merge pull request #37892 from Edouard-chin/ec-bring-back-drawing-external-routes
Bring back feature that allows loading external route files:
2019-12-06 11:10:26 -03:00
Carlos Antonio da Silva 732cfd2781 Remove extraneous `begin..end` around single `case` statement 2019-12-06 10:33:16 -03:00
Edouard CHIN 33bf253282 Bring back feature that allows loading external route iles:
= This feature existed back in 2012 5e7d6bba79
  but got reverted with the incentive that there was a better approach.
  After discussions, we agreed that it's a useful feature for apps
  that have a really large set of routes.

  Co-authored-by: Yehuda Katz <wycats@gmail.com>
2019-12-06 14:20:12 +01:00
Xavier Noria 66197a3a40 unlinks Ruby on Rails Tutorial [skip ci]
I added myself links to the Ruby on Rails Tutorial years ago, after
meeting Michael in a RailsConf.

By then, the book was a commercial product, but had a free online
version and I thought it could be a good resource complementing the
official documentation.

Nowadays, only a few sample chapters are available for free, and I
don't consider these links to be fair with the rest of commercial
books about Rails anymore.
2019-12-06 11:26:24 +01:00
Ryuta Kamizono 9c139f82db
Merge pull request #37898 from tgxworld/revert_evented_routes_reloader
Revert "Use `app.config.file_watcher` for watcher in `RoutesReloader`"
2019-12-06 16:10:42 +09:00
Alan Tan 767cec041d Revert "Use `app.config.file_watcher` for watcher in `RoutesReloader`"
This reverts commit 28e44f472d.

A limitation of Listen is that it currently only supports watching directories.
Therefore, watching `config/routes.rb` will end up watching the entire `config` directory
if we use the evented file watcher. This causes problems especially if symlinks are present
in the `config` directory.
2019-12-06 14:58:07 +08:00
Ryuta Kamizono 3ae38069e9
Merge pull request #37792 from glaszig/fix/actiondispatch/non-headless-driver-options
system tests: properly set driver options for non-headless drivers
2019-12-06 13:41:50 +09:00
Ryuta Kamizono 3b0c3124b1
Merge pull request #37853 from tgxworld/use_proper_file_watcher
Use `app.config.file_watcher` for watcher in `RoutesReloader`
2019-12-06 09:59:14 +09:00
Ryuta Kamizono 2821e8d02a
Merge pull request #37896 from tgxworld/upgrade_listen
Upgrade listen to 3.2.1 for darwin fixes
2019-12-06 09:49:54 +09:00
George Claghorn 317760c5ad Use ActiveStorage::Preview#url instead of deprecated #service_url 2019-12-05 19:41:04 -05:00
Alan Tan c9430dba39 Upgrade listen to 3.2.1 for darwin fixes
Pulls in a fix where the darwin adapter no longers create a `fsevent_watch` process
for each directory that Listen has been asked to watch.
2019-12-06 08:21:24 +08:00
Kasper Timm Hansen 6f45307960
Merge pull request #37666
Closes #37666
2019-12-05 21:51:41 +01:00
Santiago Bartesaghi 8872ec431a
perform_caching config affects collection caching 2019-12-05 21:46:02 +01:00
George Claghorn 9e06289a3b Switch to the writer DB to generate ASt previews 2019-12-05 12:56:42 -05:00
Ryuta Kamizono 34d66ca6ba
Merge pull request #37693 from elia/patch-1
Don't parse DB specific locking docs as code

[ci skip]
2019-12-05 12:29:27 +09:00
Ryuta Kamizono 868bf88354
Merge pull request #37744 from seejohnrun/around_action-docs
Add guide for inline around_action
2019-12-05 11:38:33 +09:00
George Claghorn 96d31ac9cd Style 2019-12-04 21:10:58 -05:00
Ryo Nakamura c12997fcff Add bug report templates for Active Storage 2019-12-04 21:02:43 -05:00
yuuji.yaginuma 0f724a3111 Revert "Merge pull request #37881 from pierredemilly/patch-1"
This reverts commit 5bbb2a6521, reversing
changes made to f9e4906c37.

Reason: Since #36866, we use `azure-storage-blob` gem. So the original
description is correct.
2019-12-05 08:28:35 +09:00