- 11 1月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
`relation.exists?` just wants to know if there is a result or not, does not need the exact records matched. Therefore, an intermediate SELECT query for eager loading is not necessary.
-
由 Bart de Water 提交于
[ci skip] setting :inverse_of works with :as, :through and :polymorphic options, and is needed for bi-directionality with a scope [ci skip] Remove :conditions opion from association basics guide This got replaced by scopes.
-
- 10 1月, 2018 3 次提交
-
-
由 Ryuta Kamizono 提交于
Need reloading when through record has replaced.
-
由 Ryuta Kamizono 提交于
I removed redundant `Array.wrap(records)` since `Preloader` is nodoc class and Active Record always pass `records` as an array to `Preloader`. But if users relies on that behavior, it is not worth dropping its behavior. Fixes #31661.
-
由 Brian Christian 提交于
-
- 07 1月, 2018 6 次提交
-
-
由 Ryuta Kamizono 提交于
Currently deleting through records doesn't respect `source_type`. It should not be ignored in that case. Related #23209. Fixes #24116.
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
We can use `relation.last(index)[-index]` instead of loading all records when using reversible order because `last` will call `reverse_order`.
-
由 Ryuta Kamizono 提交于
Currently `last` with `offset` behaves incorrectly because `offset` can not be reversed like `limit`. Therefore, `offset` should also be handled like `limit`.
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Commit 4ec5b0d6 was for fixing the regression #18787, but #28379 fixes #18787 as well. So 4ec5b0d6 is no longer necessary.
-
- 05 1月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of 09cac8c6.
-
- 04 1月, 2018 4 次提交
-
-
由 Ryuta Kamizono 提交于
This is a partial revert of #26182. There is no reason to change the default value.
-
由 Ryuta Kamizono 提交于
Currently reflections keeps the order when first added even if when redefining association. As a result of the order, redefining through association which use newly added association will raise `HasManyThroughOrderError`. We need to redefine reflection order as well when redefining association. Fixes #31068.
-
由 Ryuta Kamizono 提交于
This method which is used only in the internal was introduced in ac384820 and was renamed in #17579. It does not need to be exposed.
-
由 yuuji.yaginuma 提交于
An empty string is an invalid value in Ruby's range class. So need to handle `Float::INFINITY` as it is and cast it in `encode_range`. Fixes #31612
-
- 01 1月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
This method was introduced in #26718, which is internally used only in `CollectionAssociation`. There is no need to be in the reflection classes.
-
由 Ryuta Kamizono 提交于
Refactor delegating `join_primary_key` instead of `join_keys` and `association_primary_key` in `TableMetadata` Because `join_primary_key` is called by `join_keys` and it is to abstract calling `association_primary_key`.
-
- 31 12月, 2017 1 次提交
-
-
由 fatkodima 提交于
-
- 30 12月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
We can't replace existing SELECT list as long as having DISTINCT, it will cause incorrect result. And also, PostgreSQL has a limitation that ORDER BY expressions must appear in select list for SELECT DISTINCT. Therefore, we should not replace existing SELECT list when using DISTINCT. Fixes #29779.
-
- 29 12月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
We can't replace existing select list as long as referenced by ORDER BY.
-
- 27 12月, 2017 1 次提交
-
-
由 Bogdan Gusiev 提交于
when model is added to collection association
-
- 26 12月, 2017 2 次提交
-
-
由 Ryuta Kamizono 提交于
Originally I tried to add `assert_equal pk.sql_type, ref.sql_type`. But the assert failed even though the same type due to `sql_type` of primary key in SQLite is upper case. Prefer lower case like other types.
-
由 fatkodima 提交于
-
- 22 12月, 2017 1 次提交
-
-
由 Mike Busch 提交于
update_attribute previously stopped execution, before saving and before running callbacks, if the record's attributes hadn't changed. [The documentation](http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-update_attribute) says that "Callbacks are invoked", which was not happening if the persisted attributes hadn't changed.
-
- 20 12月, 2017 5 次提交
-
-
由 Ivan Zinovyev 提交于
-
由 Ryuta Kamizono 提交于
Follow up of #31177.
-
由 Ryuta Kamizono 提交于
Like other query bang methods.
-
由 Eugene Kenny 提交于
The `app:update` rake task will regenerate `development.rb` so that it contains this option; that means we're currently adding it to existing apps in two places, which is unnecessary and confusing. Also: - Remove inaccurate comment about which stack frames are ignored - Clarify that the feature uses `caller_locations`, not `caller` - Remove unused return value in `extract_callstack`
-
由 Ryuta Kamizono 提交于
Currently `count(:all)` with `distinct` doesn't work correctly because SELECT list is always replaced to `*` or primary key in that case even if having custom SELECT list. And also, PostgreSQL has a limitation that ORDER BY expressions must appear in select list for SELECT DISTINCT. Therefore, we should not replace custom SELECT list when using `count(:all)` with `distinct`. Closes #31277.
-
- 19 12月, 2017 3 次提交
-
-
由 Ryuta Kamizono 提交于
Otherwise it will occur syntax error if primary key is a reserved word.
-
由 Ryuta Kamizono 提交于
Arel doesn't support subselect generation for DELETE unlike UPDATE yet, but we already have that generation in connection adapters. We can simply use the subselect generated by that one.
-
由 Ryuta Kamizono 提交于
Most RDBMS (except SQLite) requires subselect for UPDATE with OFFSET, but Arel doesn't support executable subselect generation for MySQL's UPDATE yet. We need to use the subselect generated by the connection adapter for now, it works well. Fixes #30148.
-
- 18 12月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Previously table name qualified `*` is used in that case. If it is not qualified with a table name, an ambiguous column name error will occur when using JOINs.
-
- 17 12月, 2017 1 次提交
-
-
由 Chris Salzberg 提交于
If we don't do this, then we end up with an inconsistent situation where a parent class may e.g. reset column information, but child classes will contine to see attribute methods as already generated, and thus not pick up this new column (falling through to method_missing).
-
- 15 12月, 2017 1 次提交
-
-
由 Yoshiyuki Hirano 提交于
-
- 14 12月, 2017 2 次提交
-
-
由 Olivier Lacan 提交于
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).
-
由 Yasuo Honda 提交于
`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) ```
-
- 13 12月, 2017 2 次提交
-
-
由 Ryuta Kamizono 提交于
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.
-
由 Hiroyuki Morita 提交于
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) ```
-