- 10 5月, 2020 12 次提交
-
-
由 Ryuta Kamizono 提交于
Before IN clause optimization 70ddb8a7, Active Record had generated an SQL with binds when `prepared_statements: true`: ```ruby # prepared_statements: true # # SELECT `authors`.* FROM `authors` WHERE `authors`.`id` IN (?, ?, ?) # # prepared_statements: false # # SELECT `authors`.* FROM `authors` WHERE `authors`.`id` IN (1, 2, 3) # Author.where(id: [1, 2, 3]).to_a ``` But now, binds in IN clause is substituted regardless of whether `prepared_statements: true` or not: ```ruby # prepared_statements: true # # SELECT `authors`.* FROM `authors` WHERE `authors`.`id`IN (1,2,3) # # prepared_statements: false # # SELECT `authors`.* FROM `authors` WHERE `authors`.`id`IN (1,2,3) # Author.where(id: [1, 2, 3]).to_a ``` I suppose that is considered as a regression for the context: > While I would prefer that we fix/avoid the too-many-parameters problem, but I don't like the idea of globally ditching bind params for this edge case... we're getting to the point where I'd almost consider anything that doesn't use a bind to be a bug. https://github.com/rails/rails/pull/33844#issuecomment-421000003 This makes binds consider whether `prepared_statements: true` or not (i.e. restore the original behavior as before), but still gain that optimization when need the substitute binds (`prepared_statements: false`, `relation.to_sql`). Even when `prepared_statements: true`, it still much faster than before by optimized (bind node less) binds generation. ```ruby class Post < ActiveRecord::Base end ids = (1..1000).each.map do |n| Post.create!.id end puts "prepared_statements: #{Post.connection.prepared_statements.inspect}" Benchmark.ips do |x| x.report("where with ids") do Post.where(id: ids).to_a end end ``` * Before (200058b0) `prepared_statements: true`: ``` Warming up -------------------------------------- where with ids 6.000 i/100ms Calculating ------------------------------------- where with ids 63.806 (± 7.8%) i/s - 318.000 in 5.015903s ``` `prepared_statements: false`: ``` Warming up -------------------------------------- where with ids 7.000 i/100ms Calculating ------------------------------------- where with ids 73.550 (± 8.2%) i/s - 371.000 in 5.085672s ``` * Now with this change `prepared_statements: true`: ``` Warming up -------------------------------------- where with ids 9.000 i/100ms Calculating ------------------------------------- where with ids 91.992 (± 7.6%) i/s - 459.000 in 5.020817s ``` `prepared_statements: false`: ``` Warming up -------------------------------------- where with ids 10.000 i/100ms Calculating ------------------------------------- where with ids 104.335 (± 8.6%) i/s - 520.000 in 5.026425s ```
-
由 Ryuta Kamizono 提交于
Eager generate relation methods if a method is on `Kernel`
-
由 Ryuta Kamizono 提交于
Follow up of #34122. Relation method call is relying on method_missing, but if `Kernel` has the same named method (e.g. `open`, etc), it will invoke Kernel's method since method_missing is not happened. To prevent that, eager generate relation methods if a method is the same name on `Kernel`. Fixes #39195.
-
由 Ryuta Kamizono 提交于
dfa439ee 6708f3a5
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
`singleton_class` is in Ruby 1.9.2, and there is no use singleton class eval in the files.
-
由 Ryuta Kamizono 提交于
Refactor index creation to use index definition visitor
-
由 Ryuta Kamizono 提交于
Current SQL generation code is hard to maintenance, I've found a bug that create index comment in bulk change table when I'm refactoring that.
-
由 Ryuta Kamizono 提交于
I've found the bug when I'm refactoring index creation code in #39203.
-
由 Ryuta Kamizono 提交于
Add tests for to_s(:inspect)
-
- 09 5月, 2020 9 次提交
-
-
由 akinomaeni 提交于
-
由 Jonathan Hefner 提交于
Association callbacks work with abort instead of exceptions [ci skip]
-
由 Petrik 提交于
To prevent an object from being added/removed from an association an abort must be thrown, not an Exception.
-
由 John Hawthorn 提交于
Support kwargs for named scopes
-
由 Ryuta Kamizono 提交于
We fixed `generate_relation_method` to address kwargs warnings at #38038, but I missed generated named scopes also need the same fix. Test case has picked from #39196. Co-authored-by: NJohn Hawthorn <john@hawthorn.email>
-
由 Ryuta Kamizono 提交于
We now always use `arel_attribute` for attribute alias resolution.
-
由 Ryuta Kamizono 提交于
Positional hash argument should not be dup-ed.
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
Make NameError#missing_name work even for real Ruby NameError
-
- 08 5月, 2020 14 次提交
-
-
由 Jean Boussier 提交于
On constant missing Ruby call `#inspect` on the receiver to build the error message. For instance, the error message for `Foo::Bar` will be `"#{Foo.inspect}::Bar"`. And since Active Record override the model classes inspect method, this breaks `missing_name` assumptions. Until now it worked because missing_name was only called on errors raised by the classic autoloader, and the classic autoloader calls `#name` to build its error message.
-
由 Akira Matsuda 提交于
-
由 y-yagi 提交于
Add `config.generators.after_generate` for processing to generated files
-
由 Ryuta Kamizono 提交于
`remove_foreign_key` doesn't care `:validate` option if database has no feature
-
由 yuuji.yaginuma 提交于
Register a callback that will get called right after generators has finished. This is useful if users want to process generated files. For example, can execute an autocorrect of RuboCop for generated files as like following. ```ruby config.generators.after_generate do |files| system("bundle exec rubocop --auto-correct " + files.join(" "), exception: true) end ```
-
由 Ryuta Kamizono 提交于
Fixes #39170. #39170 is a regression caused by 362348b5 to maintain kwargs flag to address kwargs warnings.
-
由 Santiago Bartesaghi 提交于
-
由 Rafael França 提交于
Support procs for assert_{enqueued,performed}_with
-
由 Kasper Timm Hansen 提交于
Recognize Windows-style paths in test runner
-
由 Jonathan Hefner 提交于
PR #33995 added support for specifying the `args` argument of `assert_enqueued_with` and `assert_performed_with` as a matcher proc. In doing so, it added undocumented support for specifying the other arguments as matcher procs as well. This commit officially documents that support, and adds tests to ensure the behavior.
-
由 Jonathan Hefner 提交于
Fix assert_{enqueued,performed}_with doc examples [ci skip]
-
由 Jonathan Hefner 提交于
Add a link between config.cache_store in configuration.md and cache_store documentation
-
由 jean-francois labbe 提交于
Co-authored-by: NJonathan Hefner <jonathan@hefner.pro>
-
由 Jonathan Hefner 提交于
The example tests in the method docs for `assert_enqueued_with` and `assert_performed_with` previously specified `queue` args in their assertions but not in their setups. Thus, the example tests would not pass as written. This commit fixes the examples, and properly demonstrates the `queue` arg.
-
- 07 5月, 2020 5 次提交
-
-
由 Rafael França 提交于
Load selenium/webdriver only if needed
-
由 Vladimir Dementyev 提交于
Currently, 'selenium-webdriver' gem is required to use system tests even if a non-selenium driver is used (such as Poltergeist, Cuprite, etc.). We should require it only if Selenium is used by a user
-
由 Jonathan Hefner 提交于
Clarify that belongs_to is not always a one-to-one relation [ci skip]
-
由 Jonathan Hefner 提交于
"it's" => "its"
-
由 Ryuta Kamizono 提交于
Fix the result of aggregations to maintain duplicated "group by" fields
-