- 13 5月, 2020 8 次提交
-
-
由 Ryuta Kamizono 提交于
That issues are caused by using only the model's cast types on the relation. To fix that issues, use the attribute's type caster takes precedence over the model's cast types on the relation. Fixes #35232. Fixes #36042. Fixes #37484.
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Association look up requires association class is loaded especially for through association. Just apply that look up only in aggregation column for now.
-
由 Ryuta Kamizono 提交于
Follow up of #39255. Previously aggregation functions only use the model's attribute types on the relation for type cast, this will be looking up association's attribute and type caster if a column name is table name qualified. Fixes #39248.
-
由 Eugene Kenny 提交于
Followup to b3102205.
-
由 John Hawthorn 提交于
A previous change made singleton methods eagerly define their relation methods if it shared a name with a method on Kernel. This caused issues with a few methods which were both defined on Kernel and on AcitveRecord::Relation. This commit avoids defining the method if it exists on AR::Relation.
-
由 eileencodes 提交于
Since we're checking `serializable?` in the new `HomogeneousIn` `serialize` will no longer raise an exception. We implemented `unchecked_serialize` to avoid raising in these cases, but with some of our refactoring we no longer need it. I discovered this while trying to fix a query in our application that was not properly serializing binary columns. I discovered that in at least 2 of our active model types we were not calling the correct serialization. Since `serialize` wasn't aliased to `unchecked_serialize` in `ActiveModel::Type::Binary` and `ActiveModel::Type::Boolean` (I didn't check others but pretty sure all the AM Types are broken) the SQL was being treated as a `String` and not the correct type. This caused Rails to incorrectly query by string values. This is problematic for columns storing binary data like our emoji columns at GitHub. The test added here is an example of how the Binary type was broken previously. The SQL should be using the hex values, not the string value of "🥦" or other emoji. We still have the problem `unchecked_serialize` was supposed to fix - that `serialize` shouldn't validate data, just convert it. We'll be fixing that in a followup PR so for now we should use `serialize` so we know all the values are going through the right serialization for their SQL.
-
由 Ryuta Kamizono 提交于
This is the opposite direction of #39039. #39111 fixes `minimum` and `maximum` on date columns with type casting by column type on the database. But column type has no information for time zone aware attributes, it means that attribute type should always be precedence over column type. I've realized that fact in the related issue report #39248. I've reverted the expectation of #39039, to make time zone aware attributes works.
-
- 12 5月, 2020 1 次提交
-
-
由 Adam Lassek 提交于
Per [this discussion][arel-discussion] on the discourse forum, this is an addition to Arel for supporting `@>` (contains) and `&&` (overlaps) operators in PostgreSQL. They are useful for GIN-indexed data such as a `jsonb` or array column. [arel-discussion]: https://discuss.rubyonrails.org/t/what-has-happened-to-arel/74383/51
-
- 11 5月, 2020 3 次提交
-
-
由 Aidan Haran 提交于
-
由 Jean Boussier 提交于
Profiling our application boot shows this method at 1.3% of boot time: ``` ActiveRecord::AttributeMethods::ClassMethods#dangerous_attribute_method? (/tmp/bundle/ruby/2.7.0/bundler/gems/rails-4919b459d946/activerecord/lib/active_record/attribute_methods.rb:100) samples: 5 self (0.0%) / 866 total (1.3%) callers: 866 ( 100.0%) ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods#dangerous_attribute_method? callees (861 total): 861 ( 100.0%) ActiveRecord::AttributeMethods::ClassMethods#method_defined_within? ``` [A quick benchmark](https://gist.github.com/casperisfine/0ce1161253ab643f5f15ff63e901b818) shows that we can make it 2 to 3 times faster by precomputing the list of dangerous methods, and doing a simple set lookup. Of course this isn't strictly equivalent, as it's no longer dynamic, so if you include a module in `AR::Base` after the list was computed, new dangerous methods won't be considered. But at the same time, if the list was already computed, it means you defined attribute methods before AR::Base was fully initialized. `dangerous_class_method?` is pretty much invisible on profiles, but I applied the same optimization to it for consistency's sake.
-
由 Yasuo Honda 提交于
`ReadOnlyTest#test_field_named_field` performs implicit commit the transaction by `ReadOnlyTest#setup` because of the MySQL database behavior. This commit addresses the failure at https://buildkite.com/rails/rails/builds/68962#68213887-1cef-4f76-9c95-aebc8799c806 Here are minimum steps to reproduce: ```ruby % ARCONN=mysql2 bin/test test/cases/readonly_test.rb test/cases/dirty_test.rb test/cases/associations/inner_join_association_test.rb \ -n "/^(?:ReadOnlyTest#(?:test_has_many_with_through_is_not_implicitly_marked_readonly)|DirtyTest#(?:test_field_named_field)|InnerJoinAssociationTest#(?:test_eager_load_with_string_joins))$/" --seed 50855 Using mysql2 Run options: -n "/^(?:ReadOnlyTest#(?:test_has_many_with_through_is_not_implicitly_marked_readonly)|DirtyTest#(?:test_field_named_field)|InnerJoinAssociationTest#(?:test_eager_load_with_string_joins))$/" --seed 50855 ..F Failure: InnerJoinAssociationTest#test_eager_load_with_string_joins [/Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/associations/inner_join_association_test.rb:87]: Expected: 3 Actual: 4 bin/test test/cases/associations/inner_join_association_test.rb:82 Finished in 0.114674s, 26.1611 runs/s, 26.1611 assertions/s. 3 runs, 3 assertions, 1 failures, 0 errors, 0 skips ``` References: - "13.3.3 Statements That Cause an Implicit Commit" https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html
-
- 10 5月, 2020 9 次提交
-
-
由 akinomaeni 提交于
datetime with precision was passing assert_no_microsecond_precision unintentionally, because `/\d\z/` is match to both datetime with precision and datetime without precision. Fixed that by changing time and regex to make it easier to grasp with and without precision. Fix stub_version to consider schema_cache. ref: #35795 Remove failing test for unsupported version of MariaDB. ref: fb6743ac
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Since MySQL 8.0.12, MySQL supports `ALGORITHM=INSTANT` DDL option. https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html#online-ddl-index-operations
-
由 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 提交于
-
由 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 2 次提交
-
-
由 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