Commit Graph

72888 Commits

Author SHA1 Message Date
Xavier Noria 9b5401fcc9 depend on Zeitwerk 2.1.0 2019-04-09 11:06:44 +02:00
प्रथमेश Sonpatki 496e8ee937
Merge pull request #35903 from ryohashimoto/fix_upsert_method_comment
[ci skip] Fix `#upsert` method comment
2019-04-09 10:28:34 +05:30
Ryo Hashimoto ab6da0c4a8 Fix upsert method comment
Because this method only updates or inserts a single record
like `insert` method.
2019-04-09 12:06:25 +09:00
Matthew Draper e485c14a3e s/Travis/Buildkite/ 2019-04-09 11:28:49 +09:30
Matthew Draper 95fee9438b
Merge pull request #34800 from mqchau/mysqlCountDeleteRowInLock
Wrap Mysql count of deleted rows in lock block to avoid conflict in test
2019-04-09 09:44:04 +09:30
Ryuta Kamizono a497ece3f7
Merge pull request #35887 from kamipo/argument_error
Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options
2019-04-09 04:41:28 +09:00
Ryuta Kamizono 35d388b2e9
Merge pull request #35890 from kamipo/except_table_name_from_column
Except `table_name` from column objects
2019-04-09 04:39:15 +09:00
Quan Chau 66762b81f4 Wrap Mysql count of deleted rows in lock block to avoid conflict in test 2019-04-08 12:02:41 -07:00
Eileen M. Uchitelle 61073e3190
Merge pull request #35888 from lxxxvi/documentation_change_foreign_keys_to_bigint_in_association_basics
change `t.integer` to `t.bigint` where applicable
2019-04-08 11:27:17 -04:00
Eileen M. Uchitelle 27c3ad0ac0
Merge pull request #35892 from ryohashimoto/bulk_insert_logs
Improve log messages for #insert_all` / `#upsert_all` etc. methods
2019-04-08 11:26:31 -04:00
Rafael França 3f0a25ad83
Merge pull request #35897 from soartec-lab/update_guide_engine
Update configuration of `app` directory and use oxford comma [skip ci]
2019-04-08 11:20:18 -04:00
soartec-lab 1c37f6ba63 Update configuration of `app` directory and use oxford comma [skip ci] 2019-04-09 00:05:54 +09:00
Ryuta Kamizono 652ce83a4d
Merge pull request #35854 from boblail/fix-bug-with-insert_all-on-mysql
When skipping duplicates in bulk insert on MySQL, avoid assigning an AUTONUMBER column when not specified
2019-04-08 23:54:07 +09:00
Ryo Hashimoto 54dce6870d Improve log messages for #insert_all` / `#upsert_all` / `#insert` / `#upsert etc. methods
In #35077, `#insert_all` / `#upsert_all` / `#insert` / `#upsert` etc. methods are added. But Active Record logs only “Bulk Insert” log messages when they are invoked.

This commit improves the log messages to use collect words for how invoked them.
2019-04-08 23:20:14 +09:00
Bob Lail c24efdbd27 When skipping duplicates in bulk insert on MySQL, avoid assigning id when not specified
If `id` is an `AUTONUMBER` column, then my former strategy here of assigning `no_op_column` to an arbitrary column would fail in this specific scenario:

1. `model.columns.first` is an AUTONUMBER column
2. `model.columns.first` is not assigned in the insert attributes

I added three tests: the first test covers the actual error; the second test documents that this _isn't_ a problem when a value is given for the AUTONUMBER column and the third test ensures that this no-op strategy isn't secretly doing an UPSERT.
2019-04-08 08:01:40 -05:00
प्रथमेश Sonpatki dbd3ce6160
Merge pull request #35883 from alexcameron89/add_ar_release_notes
[ci-skip] Add 6.0 Release Notes for Active Record
2019-04-08 18:17:29 +05:30
Alex Kitchens 44161582d5 [ci skip] Add 6.0 Release Notes for Active Record 2019-04-08 07:18:50 -05:00
Ryuta Kamizono f185e0ebc9 Except `table_name` from column objects
The `table_name` was added at #23677 to detect whether serial column or
not correctly.

We can do that detection before initialize column object, it makes
column object size smaller, and it probably helps column object
de-duplication.
2019-04-08 19:23:26 +09:00
Ryuta Kamizono bf1494a101 Fix GROUP BY with calculate longer name field to respect `table_alias_length`
Follow up of c9e4c848ee.
2019-04-08 17:46:46 +09:00
Xavier Noria 57c7cbb162 depend on Zeitwerk 2 2019-04-07 13:05:26 +02:00
lxxxvi cdaa4baecc change `t.integer` to `t.bigint` where applicable 2019-04-07 11:35:45 +02:00
Ryuta Kamizono 20da6c7eac Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options
When I've added new `:size` option in #35071, I've found that invalid
`:limit` and `:precision` raises `ActiveRecordError` unlike other
invalid options.

I think that is hard to distinguish argument errors and statement
invalid errors since the `StatementInvalid` is a subclass of the
`ActiveRecordError`.

c9e4c848ee/activerecord/lib/active_record/errors.rb (L103)

```ruby
begin
  # execute any migration
rescue ActiveRecord::StatementInvalid
  # statement invalid
rescue ActiveRecord::ActiveRecordError, ArgumentError
  # `ActiveRecordError` except `StatementInvalid` is maybe an argument error
end
```

I'd say this is the inconsistency worth fixing.

Before:

```ruby
add_column :items, :attr1, :binary,   size: 10      # => ArgumentError
add_column :items, :attr2, :decimal,  scale: 10     # => ArgumentError
add_column :items, :attr3, :integer,  limit: 10     # => ActiveRecordError
add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
```

After:

```ruby
add_column :items, :attr1, :binary,   size: 10      # => ArgumentError
add_column :items, :attr2, :decimal,  scale: 10     # => ArgumentError
add_column :items, :attr3, :integer,  limit: 10     # => ArgumentError
add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
```
2019-04-07 16:14:42 +09:00
Ryuta Kamizono c9e4c848ee Don't repeat same expression in SELECT and GROUP BY clauses
This refactors `execute_grouped_calculation` and slightly changes
generated GROUP BY queries, since I'd not prefer to repeat same
expression in SELECT and GROUP BY clauses.

Before:

```
SELECT COUNT(*) AS count_all, "topics"."author_name" AS topics_author_name, COALESCE(type, title) AS coalesce_type_title FROM "topics" GROUP BY "topics"."author_name", COALESCE(type, title)
```

After:

```
SELECT COUNT(*) AS count_all, "topics"."author_name" AS topics_author_name, COALESCE(type, title) AS coalesce_type_title FROM "topics" GROUP BY topics_author_name, coalesce_type_title
```

Although we generally don't guarantee to support Arel node constructed
by user itself, this also fixes #24207.
2019-04-06 15:06:49 +09:00
Ryuta Kamizono 0856f7c744 There is no need to check `null_relation?` in `empty_scope?`
`values[:extending]` includes `NullRelation` if `null_relation?`.
2019-04-06 12:00:17 +09:00
Ryuta Kamizono 56b4fdb52b Association loading isn't to be affected by null relation scoping
Follow up of #35868.

Closes #19349.
2019-04-06 11:37:34 +09:00
Ryuta Kamizono e9d1d76686
Merge pull request #35868 from kamipo/association_isnt_to_be_affected_by_scoping_consistently
Association loading isn't to be affected by scoping consistently
2019-04-06 04:57:28 +09:00
प्रथमेश Sonpatki 808c589fd8
The default value without loading railtie is false [ci skip] (#35881)
See https://github.com/rails/rails/pull/35873#issuecomment-480333333
for reference

[Prathamesh Sonpatki, bogdanvlviv]
2019-04-05 22:13:03 +05:30
Eileen M. Uchitelle 8c6fedffa1
Merge pull request #35873 from prathamesh-sonpatki/enqueuing-fixes
Fix the deprecation warning about `config.active_job.return_false_on_aborted_enqueue`
2019-04-05 11:45:48 -04:00
Ryuta Kamizono 969f2c1dc9
Merge pull request #35876 from abhaynikam/fix-typo-for-touch-later-test-case
Fix typo for touch later test description. laster -> later
2019-04-05 23:38:05 +09:00
Abhay Nikam 13126e723e Fix typo for touch later test description. laster -> later 2019-04-05 19:33:19 +05:30
प्रथमेश Sonpatki a8328f61b6
Add Active Job release notes [ci skip] (#35872) 2019-04-05 15:42:01 +05:30
Prathamesh Sonpatki c35f7b5115
Fix the deprecation warning about `config.active_job.return_false_on_aborted_enqueue`
- It will return false in Rails 6.1 not 6.0. Also fixed the default
  value which is true for new applications.
2019-04-05 15:40:34 +05:30
Ryuta Kamizono 902c06f835
Merge pull request #35871 from kamipo/klass_level_touch_all
Add missing `touch_all` delegation to relation
2019-04-05 17:59:47 +09:00
Ryuta Kamizono 824ea8d06f Add missing `touch_all` delegation to relation
Follow up of #31513.
2019-04-05 16:13:40 +09:00
Ryuta Kamizono bd1e9a1b98
Merge pull request #35870 from abhaynikam/mark-touch-later-as-private-doc
[ci skip] Mark ActiveRecord::TouchLater as private doc
2019-04-05 15:36:01 +09:00
Abhay Nikam 65cd6d9e9a [ci skip] Mark ActiveRecord::TouchLater as private doc 2019-04-05 10:38:17 +05:30
Yuji Yaginuma 95a1d8721c
Merge pull request #35867 from y-yagi/do_not_exclude_paths_in_global_level
Do not exclude paths in the global level of Code Climate
2019-04-05 13:38:44 +09:00
Ryuta Kamizono 17f2f3054c Association loading isn't to be affected by scoping consistently
Follow-up of 5c71000, #29834, and #30271.

Currently, preloading and eager loading are not to be affected by
scoping, with the exception of `unscoped`.

But non eager loaded association access is still affected by scoping.

Although this is a breaking change, the association loading will work
consistently whether preloaded / eager loaded or not.

Before:

```ruby
Post.where("1=0").scoping do
  Comment.find(1).post                   # => nil
  Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
  Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
end
```

After:

```ruby
Post.where("1=0").scoping do
  Comment.find(1).post                   # => #<Post id: 1, ...>
  Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
  Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
end
```

Fixes #34638.
Fixes #35398.
2019-04-05 13:21:50 +09:00
yuuji.yaginuma a7371430c5 Do not exclude paths in the global level of Code Climate
We use only RuboCop in Code Climate and exclude paths are specified in
RuboCop's setting.

The global level excludes paths should not be specified to match the
behavior of local and CodeClimate.
2019-04-05 12:59:19 +09:00
Ryuta Kamizono a11ca2ff76 `preloaded_records` no longer includes `nil` since #35496 2019-04-05 11:13:12 +09:00
Ryuta Kamizono bbd8dd9cca Bump addressable to 2.6.0 to fix warning: assigned but unused variable - startercc
https://github.com/sporkmonger/addressable/pull/270
2019-04-05 11:00:21 +09:00
Ryuta Kamizono 069f2e250a `ast` is no longer to be `nil` since #33118 2019-04-05 10:52:17 +09:00
Ryuta Kamizono 9972d8353d Remove duplicated `test_find_last`
This is completely same with `test_last`.
2019-04-05 10:02:25 +09:00
Ryuta Kamizono 3e5e1f9482
Merge pull request #35864 from kamipo/improve_left_joins
Stash `left_joins` into `joins` to deduplicate redundant LEFT JOIN
2019-04-05 08:58:53 +09:00
Vipul A M cadc5de223
Merge pull request #35863 from urkle/fix-typo-in-guides
fix typo in the guides (use Rails instead of rails) [ci skip]
2019-04-05 03:32:49 +05:30
Edward Rudd 1b645333bc fix typo in the guides (use Rails instead of rails) 2019-04-04 17:58:37 -04:00
Ryuta Kamizono 8f05035b7e Stash `left_joins` into `joins` to deduplicate redundant LEFT JOIN
Originally the `JoinDependency` has the deduplication for eager loading
(LEFT JOIN). This re-uses that deduplication for `left_joins`.

And also, This makes left join order into part of joins, i.e.:

Before:

```
association joins -> stash joins (eager loading, etc) -> string joins -> left joins
```

After:

```
association joins -> stash joins (eager loading, left joins, etc) -> string joins
```

Now string joins are able to refer left joins.

Fixes #34325.
Fixes #34332.
Fixes #34536.
2019-04-05 06:40:53 +09:00
Vipul A M a8aca02350
Merge pull request #35861 from sharang-d/after_save_commit-callback-doc
Add documentation for 'after_save_commit' [ci skip]
2019-04-05 01:43:59 +05:30
Sharang Dashputre f154d5b43d Add documentation for 'after_save_commit' [ci skip] 2019-04-05 01:37:04 +05:30
Rafael França dd972f9efe
Merge pull request #35691 from sushantmittal/add_deattach_from_in_active_support_subscriber
Adds 'detach_from' to 'ActiveSupport::Subscriber' to detach a subscriber from a namespace.
2019-04-04 15:12:54 -04:00