- 10 5月, 2020 4 次提交
-
-
由 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 提交于
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.
-
- 09 5月, 2020 3 次提交
-
-
由 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.
-
- 08 5月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
Fixes #39170. #39170 is a regression caused by 362348b5 to maintain kwargs flag to address kwargs warnings.
-
- 07 5月, 2020 5 次提交
-
-
由 Ryuta Kamizono 提交于
Actually that result is odd and hard to predictable result to me, but we should not change the public behavior without deprecation cycle. I had not intended to break any apps, so I've restored the behavior. Fixes #39171.
-
由 Ryuta Kamizono 提交于
It is possible to unscope only the column in the specified table. ```ruby posts = Post.joins(:comments).group(:"posts.hidden") posts = posts.where("posts.hidden": false, "comments.hidden": false) posts.count # => { false => 10 } # unscope both hidden columns posts.unscope(where: :hidden).count # => { false => 11, true => 1 } # unscope only comments.hidden column posts.unscope(where: :"comments.hidden").count # => { false => 11 } ``` Co-authored-by: NSlava Korolev <korolvs@gmail.com>
-
由 Ryuta Kamizono 提交于
-
由 Jonathan Hefner 提交于
Follow-up to #39147 and #39168. By adding a new purpose-specific format, we avoid potential pitfalls from concatenating format strings. We also save a String allocation per Time attribute per inspect. The new format also includes a time zone offset for more introspective inspection.
-
由 Adam Hess 提交于
DATE_FORMATS can be either a format string or a lambda we don't want to attempt to concat them with a string if we are in the lambda case
-
- 06 5月, 2020 8 次提交
-
-
由 Xavier Noria 提交于
In the AR test suite require_dependency does not make much sense. Just call vanilla require/load. Note that in the test that made explicit use of it, there are no autoload paths, and no constants have been autoloaded. In reality, the code ended up calling Kernel#load.
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
This removes an optimization that `attr.in(range_object)` acts as `attr.between(range_object` which is deprecated over 5 years ago. `attr.in` will generate exactly IN clause even if a range object is passed. Use `attr.between` instead if BETWEEN clause is what want to get. Ref https://github.com/rails/arel/pull/333.
-
由 Ryuta Kamizono 提交于
Any missing thing would be found such like #39159.
-
由 Ryuta Kamizono 提交于
Some apps would expect that type cast is not evaluated at relation build time consistently. Context: https://github.com/kamipo/rails/commit/b571c4f3f2811b5d3dc8b005707cf8c353abdf03#r31015008 https://github.com/rails/rails/pull/34303 And also this removes extra grouping on IN clause behaved as before.
-
由 Jonathan Hefner 提交于
SQLite3 does not recognize paths as file URIs unless the `SQLite3::Constants::Open::URI` flag is set. Therefore, without this flag, a path like "file::memory:" is interpreted as a filename, causing a "file::memory:" file to be created and used as the database. Most tests in `SQLite3TransactionTest` picked up this flag from `shared_cache_flags`, but a few did not. Because those tests were creating a file, the path was changed in #38620 such that it no longer pointed to an in-memory database. This commit restores the database path as "file::memory:" and ensures the URI flag is set whenever `in_memory_db?` is true.
-
由 Bogdan Gusiev 提交于
Fixes #39073
-
由 eileencodes 提交于
This reverts commit 9817d74f, reversing changes made to d326b029. Just making this easier to merge our PR in. Otherwise there's tons of conflicts and our PR is faster.
-
- 05 5月, 2020 8 次提交
-
-
由 Ryuta Kamizono 提交于
Some commits adds `**` to address kwargs warnings in Ruby 2.7, but `save` and `save!` are originally doesn't take positional arguments, so maintain both `*` and `**` is redundant. https://github.com/rails/rails/commit/6d68bb5f695414b1801c1c3952ef955a5b0b6c6a https://github.com/rails/rails/commit/09d7ce79750d08b6b9c64fd038eee285d0cbfd44 https://github.com/rails/rails/commit/51a7422c9f10cc75a3ef6bf9177324fc771d7ba4
-
由 Ryuta Kamizono 提交于
In the past, we sometimes hit missing `Symbol#start_with?` and `Symbol#end_with?`. https://github.com/rails/rails/commit/63256bc5d7dd77b2cce82df46c53249dab2dc2a8 https://github.com/rails/rails/commit/a8e812964d711fa03843e76ae50f5ff81cdc9e00 So I proposed `Symbol#start_with?` and `Symbol#end_with?` to allow duck typing that methods for String and Symbol, then now it is available in Ruby 2.7. https://bugs.ruby-lang.org/issues/16348 Using `String#starts_with?` and `String#ends_with?` could not be gained that conveniency, so it is preferable to not use these in the future.
-
由 Ryuta Kamizono 提交于
```ruby steve = Person.find_by(name: "Steve") david = Author.find_by(name: "David") relation = Essay.where(writer: steve) # Before relation.rewhere(writer: david).to_a # => [] # After relation.rewhere(writer: david).to_a # => [david] ``` For now `rewhere` only works for truly column names, doesn't work for alias attributes, nested conditions, associations. To fix that, need to build new where clause first, and then get attribute names from new where clause.
-
由 hotatekaoru 提交于
To change a NOT NULL constraint `reversible`. When changing a NOT NULL constraint, we use `ActiveRecord::ConnectionAdapters::SchemaStatements#change` method that is not reversible, so `up` and `down` methods were required. Actually, we can use `change_column_null` method if only one constraint changed, but if we want to change multiple constarints with ALTER QUERY, `up` and `down` methods were required.
-
由 Eugene Kenny 提交于
This is a remnant of the auto-explain feature, which was removed in d3688e02.
-
由 Jonathan Hefner 提交于
Example failure: https://buildkite.com/rails/rails/builds/68661#84f8790a-fc9e-42ef-a7fb-5bd15a489de8/1002-1012 The failing `destroyed_by_association` tests create an author (a DestroyByParentAuthor) and a book (a DestroyByParentBook) that belongs to that author. If the database already contains books that refer to that author's ID from previous tests (i.e. tests that disabled `use_transactional_tests`), then one of those books will be loaded and destroyed instead of the intended DestroyByParentBook book. By loading the `:books` fixtures, we ensure the database does not contain such unexpected books. Co-authored-by: NEugene Kenny <elkenny@gmail.com> Co-authored-by: NRyuta Kamizono <kamipo@gmail.com>
-
由 akinomaeni 提交于
before ``` p Knot.create => #<Knot id: 1, created_at: "2016-05-05 01:29:47"> ``` after ``` p Knot.create => #<Knot id: 1, created_at: "2016-05-05 01:29:47.116928000"> ```
- 04 5月, 2020 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
- 03 5月, 2020 5 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Eugene Kenny 提交于
Since 901d62c5, associations can only be autosaved once: after a record has been saved, `@new_record_before_save` will always be false. This assumes that records only transition to being persisted once, but there are two cases where it happens multiple times: when the transaction that saved the record is rolled back, and when the persisted record is later duplicated.
- 02 5月, 2020 4 次提交
-
-
由 Ryuta Kamizono 提交于
I supposed all aggregation functions will return numeric result in #39039, but that assumption was incorrect for `minimum` and `maximum`, if an aggregated column is non numeric type. I've restored type casting aggregated result for `minimum` and `maximum`. Fixes #39110.
-
由 Ryuta Kamizono 提交于
The type information for type casting is entirely separated to type object, so if anyone does passing a column to `type_cast` in Rails 6, they are likely doing something wrong. See the comment for more details: https://github.com/rails/rails/blob/28d815b89487ce4001a3f6f0ab684e6f9c017ed0/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L33-L42 This also deprecates passing legacy binds (an array of `[column, value]` which is 4.2 style format) to query methods on connection. That legacy format was kept for backward compatibility, instead of that, I've supported casted binds format (an array of casted values), it is easier to construct binds than existing two binds format.
-
由 Ryuta Kamizono 提交于
-
由 eileencodes 提交于
A coworker at GitHub found a few months back that if we used `santitize_sql` over `where` when we knew the values going into `where` it was a lot faster than `where`. This PR adds a new Arel node type called `HomogenousIn` that will be used when Rails knows the values are all homogenous and can therefore pick a faster codepath. This new codepath skips some of the required processing by `where` to make `wheres` with homogenous arrays faster without requiring the application author to know when to use which query type. Using our benchmark code: ```ruby ids = (1..1000).each.map do |n| Post.create!.id end Benchmark.ips do |x| x.report("where with ids") do Post.where(id: ids).to_a end x.report("where with sanitize") do Post.where(ActiveRecord::Base.sanitize_sql(["id IN (?)", ids])).to_a end x.compare! end ``` Before this PR comparing where with a list of IDs to santitize sql: ``` Warming up -------------------------------------- where with ids 11.000 i/100ms where with sanitize 17.000 i/100ms Calculating ------------------------------------- where with ids 115.733 (± 4.3%) i/s - 583.000 in 5.045828s where with sanitize 174.231 (± 4.0%) i/s - 884.000 in 5.081495s Comparison: where with sanitize: 174.2 i/s where with ids: 115.7 i/s - 1.51x slower ``` After this PR comparing where with a list of IDs to santitize sql: ``` Warming up -------------------------------------- where with ids 16.000 i/100ms where with sanitize 19.000 i/100ms Calculating ------------------------------------- where with ids 158.293 (± 6.3%) i/s - 800.000 in 5.072208s where with sanitize 169.141 (± 3.5%) i/s - 855.000 in 5.060878s Comparison: where with sanitize: 169.1 i/s where with ids: 158.3 i/s - same-ish: difference falls within error ``` Co-authored-by: NAaron Patterson <aaron.patterson@gmail.com>
-