- 05 6月, 2020 13 次提交
-
-
由 Kasper Timm Hansen 提交于
Silence Rake task backtraces
-
由 Jonathan Hefner 提交于
Silence Rake task backtraces, similar to Rails::BacktraceCleaner. Application lines are preserved, but all other lines are hidden. This also affects unrecognized tasks, causing the backtrace to be hidden entirely. Closes #39524. Co-authored-by: NPetrik <petrik@deheus.net>
-
由 Ryuta Kamizono 提交于
Follow up to #39409.
-
由 Ryuta Kamizono 提交于
It is too pessimistic, we can check the attribute whether aggregated or not by `reflect_on_aggregation`.
-
由 Ryuta Kamizono 提交于
```ruby ActiveRecord::Schema.define do create_table :posts, force: true do |t| end create_table :comments, force: true do |t| t.belongs_to :post end end class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end post = Post.create! Benchmark.ips do |x| x.report("find_by post") { Comment.find_by(post: post) } end ``` Before: ``` Warming up -------------------------------------- find_by post 395.000 i/100ms Calculating ------------------------------------- find_by post 4.026k (± 3.1%) i/s - 20.145k in 5.008059s ``` After: ``` Warming up -------------------------------------- find_by post 1.183k i/100ms Calculating ------------------------------------- find_by post 11.859k (± 2.5%) i/s - 60.333k in 5.090685s ```
-
由 Ryuta Kamizono 提交于
This reverts commit c1b8833e. Revert "Lock benchmark-ips version < 2.8" This reverts commit 62bfa50f. LoadError is fixed in benchmark-ips 2.8.2. https://github.com/evanphx/benchmark-ips/pull/101
-
由 Ryuta Kamizono 提交于
Delegating to just one line method is to not be worth it. Avoiding the delegation makes `read_attribute` about 15% faster. ```ruby ActiveRecord::Schema.define do create_table :users, force: true do |t| t.string :name end end class User < ActiveRecord::Base def fast_read_attribute(attr_name, &block) name = attr_name.to_s name = self.class.attribute_aliases[name] || name name = @primary_key if name == "id" && @primary_key @attributes.fetch_value(name, &block) end end user = User.create!(name: "user name") Benchmark.ips do |x| x.report("read_attribute('id')") { user.read_attribute('id') } x.report("read_attribute('name')") { user.read_attribute('name') } x.report("fast_read_attribute('id')") { user.fast_read_attribute('id') } x.report("fast_read_attribute('name')") { user.fast_read_attribute('name') } end ``` ``` Warming up -------------------------------------- read_attribute('id') 165.744k i/100ms read_attribute('name') 162.229k i/100ms fast_read_attribute('id') 192.543k i/100ms fast_read_attribute('name') 191.209k i/100ms Calculating ------------------------------------- read_attribute('id') 1.648M (± 1.7%) i/s - 8.287M in 5.030170s read_attribute('name') 1.636M (± 3.9%) i/s - 8.274M in 5.065356s fast_read_attribute('id') 1.918M (± 1.8%) i/s - 9.627M in 5.021271s fast_read_attribute('name') 1.928M (± 0.9%) i/s - 9.752M in 5.058820s ```
-
由 Ryuta Kamizono 提交于
Expand on specs for foreign keys with to_table and add make doc changes
-
由 Eileen M. Uchitelle 提交于
Remove assumption that a primary config exists
-
由 Eileen M. Uchitelle 提交于
Fix schema cache load and corresponding test
-
由 Vipul A M 提交于
Expand on specs of self join and add make doc changes to suggest users to also do foreign_key when doing self join
-
由 eileencodes 提交于
This test was incorrect. `primary` was winning for the schema cache load but when you boot an application it's actually the first configuration that wins (in a multi db app). The test didn't catch this because I forgot to add a migrations_paths to the configuration. We updated the schema cache loader railtie as well because any application that didn't have a `primary` config would not be able to use the schema cache. Originally we thought we'd enforce a `primary` configuration but no longer feel that's correct. It's simpler to say that the first wins in a 3-tier rather than implementing a solution to require `primary` and / or allow aliases. Co-authored-by: NJohn Crepezzi <john.crepezzi@gmail.com> Co-authored-by: NJohn Hawthorn <john@hawthorn.email>
-
由 eileencodes 提交于
Applications may not have a primary configuration so we should not assume there is one. In both these cases we can get the right connection without that. For the databases.rake file we want to re-establish a connection for the environment we're in. The first config defined under an environment for a multi-db app will win. This is already the case on application boot so we should be consistent. For the info.rb file we already have a connection so we can lookup the adapter from the connection's db_config. If a primary hadn't existed this would have thrown an exception. Followup to https://github.com/rails/rails/pull/39535 which removed the assumption there was a primary config from the schema cache load railtie. Co-authored-by: NJohn Crepezzi <john.crepezzi@gmail.com>
-
- 04 6月, 2020 16 次提交
-
-
由 Akira Matsuda 提交于
This reverts commit dd1aa738. Since this ivar is updated in a synchronize block just below, and has to be protected from other threads Co-authored-by: NRyuta Kamizono <kamipo@gmail.com>
-
由 Akira Matsuda 提交于
[ci skip]
-
由 Akira Matsuda 提交于
This reverts commit 5e0ef9ca. @num_waiting has to be synchronized with `poll` method Co-authored-by: NRyuta Kamizono <kamipo@gmail.com>
-
由 Akira Matsuda 提交于
This reverts commit ea791e53. reason: these ivars are modified within other synchronize blocks, and so need to be blocked from other threads for ensuring therad safety. Co-authored-by: NRyuta Kamizono <kamipo@gmail.com>
-
由 Jonathan Hefner 提交于
Link to current version of API docs [ci skip]
-
由 Jonathan Hefner 提交于
-
由 Ryuta Kamizono 提交于
remove redundant require: follow #39142
-
由 Yoshiyuki Kinjo 提交于
-
由 Ryuta Kamizono 提交于
It is a super edge case but the alias should be resolved before `clear_attribute_changes` since `clear_attribute_changes` is not aware of attribute aliases.
-
由 Ryuta Kamizono 提交于
Redundant `to_s` has a few overhead. Especially private methods are not intend to be passed user input directly so it should be passed always string. Removing redundant `to_s` makes attribute methods about 10% faster. ```ruby ActiveRecord::Schema.define do create_table :users, force: true do |t| end end class User < ActiveRecord::Base def fast_read_attribute(attr_name, &block) @attributes.fetch_value(attr_name, &block) end end user = User.create! Benchmark.ips do |x| x.report("user._read_attribute('id')") { user._read_attribute("id") } x.report("user.fast_read_attribute('id')") { user.fast_read_attribute("id") } end ``` ``` Warming up -------------------------------------- user._read_attribute('id') 272.151k i/100ms user.fast_read_attribute('id') 283.518k i/100ms Calculating ------------------------------------- user._read_attribute('id') 2.699M (± 1.3%) i/s - 13.608M in 5.042846s user.fast_read_attribute('id') 2.988M (± 1.2%) i/s - 15.026M in 5.029056s ```
-
由 Ryuta Kamizono 提交于
Promote `clear_attribute_change` as attribute methods
-
由 Eugene Kenny 提交于
Do not mark attributes as changed when the type is case insensitive a…
-
由 Peter Fry 提交于
Do not mark Postgresql MAC address and UUID attributes as changed when the assigned value only varies by case. Fix Rubocop warnings. Fix merge conflict error. Fix merge conflict error.
-
由 Ryuta Kamizono 提交于
For now, `increment` with aliased attribute does work, but `increment!` with aliased attribute does not work, due to `clear_attribute_change` is not aware of attribute aliases. We sometimes partially updates specific attributes in dirties, at that time it relies on `clear_attribute_change` to clear partially updated attribute dirties. If `clear_attribute_change` is not attribute method unlike others, we need to resolve attribute aliases manually only for `clear_attribute_change`, it is a little inconvinient for me. From another point of view, we have `restore_attributes`, `restore_attribute!`, `clear_attribute_changes`, and `clear_attribute_change`. Despite almost similar features `restore_attribute!` is an attribute method but `clear_attribute_change` is not. Given the above, I'd like to promote `clear_attribute_change` as attribute methods to fix issues caused by the inconsisteny.
-
由 Aaron Patterson 提交于
Make custom inspect methods more consistent
-
由 Ryuta Kamizono 提交于
-
- 03 6月, 2020 11 次提交
-
-
由 Eugene Kenny 提交于
Fix issue with expression index in insert_all
-
由 Austen Madden 提交于
Based on the docs which state unique_by option of insert_all can use the index name if desired, one would expect the method to work normally and use the `unique_by` option to determine duplicates. However, there's an issue where the insert_all expects a Set instead of the string representing the index expression it is given. This causes an error. Returning the string expression instead of attempting to format it works perfectly though.
-
由 Eugene Kenny 提交于
Replace 'Stubs out' with 'Generates' in generator USAGE's [ci skip]
-
由 Eugene Kenny 提交于
Alias direct_descendants as subclasses
-
由 Petrik 提交于
Generators generate things, but what is meant by 'Stubbing out' might confuse beginners and non-native English speakers. While generated tests are stubs that should have an implementation, a generated model is a valid model that doesn't require any changes.
-
由 fatkodima 提交于
-
由 Jonathan Hefner 提交于
This alias overrides Class#subclasses. Thus calls to `subclasses` get a free performance boost when the class extends DescendantsTracker.
-
由 Ryuta Kamizono 提交于
Support attribute aliases for `type_for_attribute`
-
由 Ryuta Kamizono 提交于
-
由 Haroon Ahmed 提交于
-
由 Ryuta Kamizono 提交于
Ensure column names on reflection as a string
-