aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #26815 from olivierlacan/log-query-sourceEileen M. Uchitelle2017-12-148-7/+97
|\ | | | | Log the original call site for an ActiveRecord query
| * Log call site for all queriesOlivier Lacan2017-12-138-7/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new ActiveRecord configuration option allows you to easily pinpoint what line of application code is triggering SQL queries in the development log by appending below each SQL statement log the line of Ruby code that triggered it. It’s useful with N+1 issues, and to locate stray queries. By default this new option ignores Rails and Ruby code in order to surface only callers from your application Ruby code or your gems. It is enabled on newly generated Rails 5.2 applications and can be enabled on existing Rails applications: ```ruby Rails.application.configure do # ... config.active_record.verbose_query_logs = true end ``` The `rails app:upgrade` task will also add it to `config/development.rb`. This feature purposely avoids coupling with ActiveSupport::BacktraceCleaner since ActiveRecord can be used without ActiveRecord. This decision can be reverted in the future to allow more configurable backtraces (the exclusion of gem callers for example).
* | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-1432-88/+83
|/ | | | Follow up of #31432.
* Use released `resque-scheduler` instead of master versionyuuji.yaginuma2017-12-142-12/+7
| | | | | The v4.3.1 has already released that includes Redis 4.0 support. https://github.com/resque/resque-scheduler/blob/master/CHANGELOG.md#431---2017-11-20
* Merge pull request #31433 from ↵Rafael França2017-12-132-0/+29
|\ | | | | | | | | jordan-brough/preserve-deprecated-method-visibility Preserve original method visibility when deprecating a method
| * Preserve original method visibility when deprecating a methodJordan Brough2017-12-132-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes `deprecate` so that it preserves method visibility (like it did previously when it was utilizing `alias_method_chain`). When Module#prepend replaced alias_method_chain in a982a42 it caused deprecated methods to always become public. `alias_method_chain` had this bit of code: https://github.com/rails/rails/blob/v5.0.6/activesupport/lib/active_support/core_ext/module/aliasing.rb#L40-L47 which preserved method visibility. Without this fix, a workaround would be: ```ruby class C8 private def new_method end def old_method end deprecate :old_method, :new_method # workaround: instance_method(:old_method).owner.send(:private, :old_method) end ``` Because the visibility needs to be fixed on the Module prepended by MethodWrapper.
* | Merge pull request #31435 from yahonda/deprecated_bigdecimal_newRafael França2017-12-1313-24/+24
|\ \ | | | | | | Suppress `warning: BigDecimal.new is deprecated` in activerecord
| * | Suppress `warning: BigDecimal.new is deprecated` in activerecordYasuo Honda2017-12-1313-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `BigDecimal.new` has been deprecated in BigDecimal 1.3.3 which will be a default for Ruby 2.5. Refer https://github.com/ruby/bigdecimal/commit/533737338db915b00dc7168c3602e4b462b23503 ``` $ cd rails/activerecord/ $ git grep -l BigDecimal.new | grep \.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g" ``` - Changes made only to Active Record. Will apply the same change to other module once this commit is merged. - The following deprecation has not been addressed because it has been reported at `ActiveRecord::Result.new`. `ActiveRecord::Result.ancestors` did not show `BigDecimal`. * Not addressed ```ruby /path/to/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:34: warning: BigDecimal.new is deprecated ``` * database_statements.rb:34 ```ruby ActiveRecord::Result.new(result.fields, result.to_a) if result ``` * ActiveRecord::Result.ancestors ```ruby [ActiveRecord::Result, Enumerable, ActiveSupport::ToJsonWithActiveSupportEncoder, Object, Metaclass::ObjectMethods, Mocha::ObjectMethods, PP::ObjectMixin, ActiveSupport::Dependencies::Loadable, ActiveSupport::Tryable, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject] ``` This commit has been tested with these Ruby and BigDecimal versions - ruby 2.5 and bigdecimal 1.3.3 ``` $ ruby -v ruby 2.5.0dev (2017-12-14 trunk 61217) [x86_64-linux] $ gem list |grep bigdecimal bigdecimal (default: 1.3.3, default: 1.3.2) ``` - ruby 2.4 and bigdecimal 1.3.0 ``` $ ruby -v ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux-gnu] $ gem list |grep bigdecimal bigdecimal (default: 1.3.0) ``` - ruby 2.3 and bigdecimal 1.2.8 ``` $ ruby -v ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux] $ gem list |grep -i bigdecimal bigdecimal (1.2.8) ``` - ruby 2.2 and bigdecimal 1.2.6 ``` $ ruby -v ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux] $ gem list |grep bigdecimal bigdecimal (1.2.6) ```
* | | Merge pull request #31432 from yhirano55/add_a_space_to_comment_in_active_jobRafael França2017-12-131-1/+1
|\ \ \ | |_|/ |/| | [ci skip] Add a space to comment in SidekiqAdapter
| * | [ci skip] Add a space to comment in SidekiqAdapterYoshiyuki Hirano2017-12-141-1/+1
| |/ | | | | | | | | * I think it's better to have a leading space after the `#` denoting the start of the comment.
* | Merge pull request #31429 from meinac/expose_activestorage_routesGeorge Claghorn2017-12-132-19/+38
|\ \ | |/ |/| Expose Active Storage routes
| * Expose Active Storage routesMehmet Emin INAC2017-12-132-19/+38
|/
* Merge pull request #31428 from yahonda/report_on_exception_true_in_ruby25Rafael França2017-12-132-0/+5
|\ | | | | Suppress expected exceptions by `report_on_exception` = `false`
| * Suppress expected exceptions by `report_on_exception` = `false` in Ruby 2.5Yasuo Honda2017-12-132-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | * Ruby 2.4 introduces `report_on_exception` to control if it reports exceptions in thread, this default value has been `false` in Ruby 2.4. Refer https://www.ruby-lang.org/en/news/2016/11/09/ruby-2-4-0-preview3-released/ * Ruby 2.5 changes `report_on_exception` default value to `true` since this commit https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=61183&view=revision This pull request suppresses expected exceptions by setting `report_on_exception` = `false` it also supports Ruby 2.3 which does not have`report_on_exception`.
* | Merge pull request #30474 from yhirano55/make_it_same_title_in_index_and_pageEileen M. Uchitelle2017-12-135-12/+12
|\ \ | | | | | | Make it same title in index and page [ci skip]
| * | Make it same title in index and page [ci skip]Yoshiyuki Hirano2017-08-315-12/+12
| | |
* | | Exclude ActiveStorage::Filename{#parameters,::Parameters} from API docs [ci ↵George Claghorn2017-12-132-2/+2
| |/ |/| | | | | skip]
* | Merge pull request #31391 from ↵Eileen M. Uchitelle2017-12-131-1/+5
|\ \ | | | | | | | | | | | | 5t111111/fix-active_storage-installation-failure-in-engine Fix active_storage installation failure when in engine
| * | Invoke app-prefixed active storage task when in engineHirofumi Wakasugi2017-12-131-1/+5
| | |
* | | Fix inheritance object creation from relationRyuta Kamizono2017-12-133-12/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to pass scope attributes to `klass.new` to detect subclass. Otherwise `subclass_from_attributes` can't detect subclass which is had in scope attributes. Fixes #18062. Closes #18227. Closes #30720.
* | | Merge pull request #31425 from chiastolite/optimize_foregin_keys_queryRyuta Kamizono2017-12-131-2/+3
|\ \ \ | | | | | | | | Optimizing information_schema query for `foreign_keys`
| * | | Optimizing information_schema query for `foreign_keys`Hiroyuki Morita2017-12-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use CONSTRAINT_SCHEMA key for information_schema.referential_constraints. See https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html. ``` > EXPLAIN SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key', fk.column_name AS 'column', fk.constraint_name AS 'name', rc.update_rule AS 'on_update', rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'activerecord_unittest' AND fk.table_name = 'fk_test_has_pk' AND rc.constraint_schema = 'activerecord_unittest' AND rc.table_name = 'fk_test_has_pk'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: rc partitions: NULL type: ALL possible_keys: NULL key: CONSTRAINT_SCHEMA,TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 0 databases *************************** 2. row *************************** id: 1 select_type: SIMPLE table: fk partitions: NULL type: ALL possible_keys: NULL key: TABLE_SCHEMA,TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 0 databases; Using join buffer (Block Nested Loop) 2 rows in set, 1 warning (0.00 sec) ```
* | | | Merge pull request #31423 from ↵Ryuta Kamizono2017-12-134-16/+51
|\ \ \ \ | |/ / / |/| | | | | | | | | | | bogdanvlviv/fix-protected_environments-with-symbols Fix protected environments with symbols
| * | | Update 'Configuring Rails Applications' guidebogdanvlviv2017-12-121-0/+4
| | | | | | | | | | | | | | | | | | | | - Add mention about `config.active_record.internal_metadata_table_name` - Add mention about `config.active_record.protected_environments`
| * | | Convert protected_environments to an array of stringsbogdanvlviv2017-12-123-16/+47
|/ / / | | | | | | | | | | | | | | | | | | These changes prevent ignoring environments name of which is a `Symbol` ``` config.active_record.protected_environments = ['staging', :production] ```
* | | Make `sanitize_sql_` methods publicyuuji.yaginuma2017-12-135-152/+151
| | | | | | | | | | | | | | | | | | | | | | | | Currently, sanitize methods are private. So need `send` to use from outside class. However, sometimes want to use sanitize methods from outside Class when want to generate SQL including multiple tables like search. In order to avoid using `send` in such a case, changed methods to public.
* | | Merge pull request #31405 from ↵Rafael França2017-12-126-8/+128
|\ \ \ | | | | | | | | | | | | | | | | bogdanvlviv/fix-conflicts-counter_cache-with-touch-by-optimistic_locking Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
| * | | Fix conflicts `counter_cache` with `touch: true` by optimistic locking.bogdanvlviv2017-12-126-8/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` # create_table :posts do |t| # t.integer :comments_count, default: 0 # t.integer :lock_version # t.timestamps # end class Post < ApplicationRecord end # create_table :comments do |t| # t.belongs_to :post # end class Comment < ApplicationRecord belongs_to :post, touch: true, counter_cache: true end ``` Before: ``` post = Post.create! # => begin transaction INSERT INTO "posts" ("created_at", "updated_at", "lock_version") VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0) commit transaction comment = Comment.create!(post: post) # => begin transaction INSERT INTO "comments" ("post_id") VALUES (1) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1, "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1 UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330', "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0 rollback transaction # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post. Comment.take.destroy! # => begin transaction DELETE FROM "comments" WHERE "comments"."id" = 1 UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1, "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1 UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901', "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0 rollback transaction # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post. ``` After: ``` post = Post.create! # => begin transaction INSERT INTO "posts" ("created_at", "updated_at", "lock_version") VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0) commit transaction comment = Comment.create!(post: post) # => begin transaction INSERT INTO "comments" ("post_id") VALUES (1) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1, "lock_version" = COALESCE("lock_version", 0) + 1, "updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1 commit transaction comment.destroy! # => begin transaction DELETE FROM "comments" WHERE "comments"."id" = 1 UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1, "lock_version" = COALESCE("lock_version", 0) + 1, "updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1 commit transaction ``` Fixes #31199.
* | | | Merge pull request #31421 from tcopeland/trivial_typoRafael França2017-12-121-1/+1
|\ \ \ \ | | | | | | | | | | Fix doc typo [ci skip]
| * | | | Fix doc typo [ci skip]Tom Copeland2017-12-121-1/+1
|/ / / /
* | | | Merge pull request #31403 from Edouard-chin/fix-quoted-columnnameRafael França2017-12-122-1/+9
|\ \ \ \ | | | | | | | | | | Quote colum_names when building select:
| * | | | Quote colum_names when building select:Edouard CHIN2017-12-112-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - #30980 introcuded a change to not use `Arel.star` when model have ignored columns, a query used to look like `SELECT *. FROM developers` whereas now it would like `SELECT column1, column2 FROM developers` - If a column has the same name has a reserved database specific keyword (such as key, where ...) then the query would fail because the names aren't quoted - Quoting almost always happen unless we use a `from` clause in the query https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1052 - This PR cast all columns name to symbols in order for the quoting logic to be picked up https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1054-L1055 - A reproduction script can be found here https://gist.github.com/Edouard-chin/f56d464a0adcb76962afc1a9134a1536
* | | | | Merge pull request #31418 from yahonda/revert_31339_to_address_31369Eileen M. Uchitelle2017-12-121-1/+4
|\ \ \ \ \ | | | | | | | | | | | | Revert "only install ffmpeg and mupdf on activestorage builds"
| * | | | | Revert "only install ffmpeg and mupdf on activestorage builds"Yasuo Honda2017-12-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6ec0ed67d9afcc666ad0424b10e9903f63e60714.
* | | | | | Merge pull request #31416 from meinac/minor_fix_on_active_support_changelogRyuta Kamizono2017-12-121-1/+1
|\ \ \ \ \ \ | |/ / / / / |/| | | | | [ci skip] Fix Active Support Changelog about :race_condition_ttl
| * | | | | [ci skip] Fix Active Support Changelog about :race_condition_ttlMehmet Emin INAC2017-12-121-1/+1
|/ / / / /
* | | | | Merge pull request #31414 from fatkodima/ignore_tables-commentRyuta Kamizono2017-12-121-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Remove stale comment about `ActiveRecord::SchemaDumper.ignore_tables` [skip ci]
| * | | | | Remove stale comment about `ActiveRecord::SchemaDumper.ignore_tables` [skip ci]fatkodima2017-12-121-1/+1
|/ / / / /
* | | | | Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-1224-43/+46
| | | | | | | | | | | | | | | | | | | | Follow up of #31390.
* | | | | Merge pull request #31411 from eugeneius/time_helpers_redefine_methodRyuta Kamizono2017-12-121-1/+2
|\ \ \ \ \ | | | | | | | | | | | | Prevent race condition when resetting time stubs
| * | | | | Prevent race condition when resetting time stubsEugene Kenny2017-12-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the current thread is preempted after the stub has been removed but before the original method has been restored, then the other thread will get a `NoMethodError` when it tries to call the method. Using `silence_redefinition_of_method` instead of `undef_method` ensures that either the stub or the original method is always in place.
* | | | | | Merge pull request #31410 from swrobel/patch-3Ryuta Kamizono2017-12-121-1/+1
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Fix secrets command deprecation message
| * | | | | Fix secrets command deprecation messageStefan Wrobel2017-12-111-1/+1
| | | | | |
* | | | | | Merge pull request #31402 from yhirano55/update_routing_guide_for_direct_methodRyuta Kamizono2017-12-121-0/+43
|\ \ \ \ \ \ | |/ / / / / |/| | | | | [ci skip] Update routing guide for Direct & resolved routes
| * | | | | [ci skip] Update routing guide for DirectYoshiyuki Hirano2017-12-121-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | * Added the direct method to routing guide.
* | | | | | Fix optimizing GIF variants using mogrify's -layers optionGeorge Claghorn2017-12-111-5/+7
| | | | | |
* | | | | | Revert "Invoke mogrify once when transforming an image"George Claghorn2017-12-111-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit a80f81af055f02bf4625c90470aa90441cf6fc24.
* | | | | | Merge pull request #31407 from Edouard-chin/remove-create-fixtures-helperRafael França2017-12-111-4/+0
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | `create_fixtures` doesn't work since at least a94220b
| * | | | | `create_fixtures` doesn't work since at least ↵Edouard CHIN2017-12-111-4/+0
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | a94220b66c9e4890007f66b092b25f8a64a19d31: - The namespacing should be `ActiveRecord::FixtureSet` - I might be missing something but I'm not sure why `create_fixtures` is useful for nowaday (unless for testing rails internal /shrug) and since it's been that long it wasn't working I think it should be fine to just fire it
* | | | | Merge pull request #31399 from yhirano55/return_nil_if_raise_http_errorGeorge Claghorn2017-12-111-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Return `nil` instead of `false` if raise `Azure::Core::Http::HTTPError`