aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | | | | When deleting through records, take into account association conditionsPiotr Jakubowski2016-05-042-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #18424. When deleting through records, it didn't take into account the conditions that may have been affecting join model table, but was defined in association definition.
* | | | | | | | | Make `relation.exists?` more performant when using eager loadingRyuta Kamizono2018-01-111-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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.
* | | | | | | | | Fix `stale_state` for nested `has_many :through` associationsRyuta Kamizono2018-01-101-12/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Need reloading when through record has replaced.
* | | | | | | | | Merge pull request #16314 from ↵Ryuta Kamizono2018-01-101-0/+29
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | zoltankiss/allow-nested-has-many-associations-on-unpersisted-parent-instances fix nested `has many :through` associations on unpersisted parent instances
| * | | | | | | | | Fix nested `has many :through` associations on unpersisted instancesZoltan Kiss2015-03-261-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: #16313
* | | | | | | | | | resolve inconsistencies between first and to_a.first with limitBrian Christian2018-01-091-0/+18
| | | | | | | | | |
* | | | | | | | | | Fix deleting through records when using has_many through with `source_type`Ryuta Kamizono2018-01-081-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently deleting through records doesn't respect `source_type`. It should not be ignored in that case. Related #23209. Fixes #24116.
* | | | | | | | | | Fix `last` with `offset` to behave consistently with loaded relationRyuta Kamizono2018-01-071-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `last` with `offset` behaves incorrectly because `offset` can not be reversed like `limit`. Therefore, `offset` should also be handled like `limit`.
* | | | | | | | | | Fix `pluck` with eager loading to respect `offset`Ryuta Kamizono2018-01-071-0/+5
| | | | | | | | | |
* | | | | | | | | | Revert commit 4ec5b0d6b4d8a57e034b1014942356e95caf47aa in favor of #28379Ryuta Kamizono2018-01-071-3/+3
| |_|_|/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4ec5b0d was for fixing the regression #18787, but #28379 fixes #18787 as well. So 4ec5b0d is no longer necessary.
* | | | | | | | | Partial revert the changing default value of `readonly_value`Ryuta Kamizono2018-01-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a partial revert of #26182. There is no reason to change the default value.
* | | | | | | | | Fix newly added reflection order when redefining associationRyuta Kamizono2018-01-042-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | Deprecate `valid_alter_table_type?` in sqlite3 adapterRyuta Kamizono2018-01-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | Correctly handle infinity value in PostgreSQL range typeyuuji.yaginuma2018-01-041-0/+12
| |_|_|_|/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | | | | Merge pull request #31331 from dinahshi/postgresql_bulk_updateMatthew Draper2018-01-032-8/+28
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Add bulk alter support for PostgreSQL
| * | | | | | | | Add bulk alter support for PostgreSQLDinah Shi2017-12-062-8/+28
| | | | | | | | |
* | | | | | | | | Merge pull request #25456 from ojab/masterRyuta Kamizono2018-01-031-1/+1
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove dormant check
* \ \ \ \ \ \ \ \ \ Merge pull request #27561 from fishbrain/count-all-in-has-many-associationRyuta Kamizono2018-01-032-0/+10
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `count(:all)` in HasManyAssociation#count_records
| * | | | | | | | | | Use `count(:all)` in HasManyAssociation#count_recordsKlas Eskilson2017-02-072-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Calling `count` on an association can cause invalid SQL queries to be created where the `SELECT COUNT(a, b, c)` function receives multiple columns. This will cause a `StatementInvalid` exception later on. Solution: Use `count(:all)`, which generates a `SELECT COUNT(*)...` query independently of the association. This also includes a test case that, before the fix, broke.
* | | | | | | | | | | Merge pull request #29018 from willbryant/missing_attributes_after_saveRyuta Kamizono2018-01-031-0/+7
|\ \ \ \ \ \ \ \ \ \ \ | |_|_|_|_|_|_|_|/ / / |/| | | | | | | | | | | | | | | | | | | | | fix the dirty tracking code's save hook overwriting missing attribute…
| * | | | | | | | | | fix the dirty tracking code's save hook overwriting missing attributes with ↵Will Bryant2017-05-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialized-to-nil attributes. fixes #29017.
* | | | | | | | | | | Add test case for `collection_singular_ids` with symbol primary keysRyuta Kamizono2018-01-012-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a regression test for #27864.
* | | | | | | | | | | Remove `association_primary_key_type` from `AssociationReflection` and ↵Ryuta Kamizono2018-01-011-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `ThroughReflection` This method was introduced in #26718, which is internally used only in `CollectionAssociation`. There is no need to be in the reflection classes.
* | | | | | | | | | | Merge pull request #31575 from bogdan/bugfix-has-many-reattachmentRyuta Kamizono2018-01-011-0/+9
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Bugfix foreign key replacement in inverse association
| * | | | | | | | | | | Bugfix foreign key replacement in inverse associationBogdan Gusiev2017-12-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when model is added to collection association
* | | | | | | | | | | | Fix recreating partial indexes after alter table for sqlitefatkodima2017-12-311-0/+17
| | | | | | | | | | | |
* | | | | | | | | | | | Fix `cache_key` with a relation having distinct and orderRyuta Kamizono2017-12-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | | | | Fix `cache_key` with a relation having custom select and orderRyuta Kamizono2017-12-291-0/+6
|/ / / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't replace existing select list as long as referenced by ORDER BY.
* | | | | | | | | | | SQLite: Add more test cases for adding primary keyRyuta Kamizono2017-12-262-58/+100
| | | | | | | | | | |
* | | | | | | | | | | Make `sql_type` of primary key in SQLite to comparable with an integer (#28008)Ryuta Kamizono2017-12-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | | | Fix `add_column` with :primary_key type compatibility for SQLitefatkodima2017-12-251-0/+19
| | | | | | | | | | |
* | | | | | | | | | | Don't pass `object_id` to `refute_nil` since `object_id` never to be nilRyuta Kamizono2017-12-261-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And prefer `assert_same` over `assert_equal`.
* | | | | | | | | | | Merge pull request #27780 from ↵Ryuta Kamizono2017-12-252-0/+10
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mikelikesbikes/fix-update-attribute-callbacks-issue save attributes changed by callbacks after update_attribute
| * | | | | | | | | | | save attributes changed by callbacks after update_attributeMike Busch2017-12-222-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | | | | Add test case for using sanitize method in the scope definitionRyuta Kamizono2017-12-221-2/+10
|/ / / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context: https://github.com/rails/rails/pull/29301#issuecomment-353200233
* | | | | | | | | | | Merge pull request #31520 from yahonda/introduce_frozen_error_classRyuta Kamizono2017-12-204-3/+7
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Handle `FrozenError` if it is available
| * | | | | | | | | | | Handle `FrozenError` if it is availableYasuo Honda2017-12-204-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull request handles `FrozenError` introduced by Ruby 2.5. Refer https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/61131 Since `FrozenError` is a subclass of `RuntimeError` minitest used by master branch can handle it, though it would be better to handle `FrozenError` explicitly if possible. `FrozenError` does not exist in Ruby 2.4 or lower, `frozen_error_class` handles which exception is expected to be raised. This pull request is intended to be merged to master, then backported to `5-1-stable` to address #31508
* | | | | | | | | | | | Remove passing needless empty string `options` in `create_table`Ryuta Kamizono2017-12-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #31177.
* | | | | | | | | | | | Merge pull request #31177 from ↵Matthew Draper2017-12-202-3/+78
|\ \ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | albertoalmagro/remove-default-mysql-engine-from-ar-5-2 Remove default ENGINE=InnoDB for Mysql2 adapter
| * | | | | | | | | | | | Remove default ENGINE=InnoDB for Mysql2 adapterAlberto Almagro2017-12-112-3/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit ENGINE=InnoDB was added by default to Mysql2 adapter +create_table+ if no +options+ option was provided. This default ENGINE was lost as soon as something was passed in at +options+ option, making its goal and propagation inconsistent, as the programmer needed to remember including ENGINE=InnoDB when something was passed in. This commit removes default ENGINE as its use isn't needed anymore for current MySQL and MariaDB versions. It adds compatibility support and tests to ensure that default ENGINE is still present for migrations with version 5.1 and before. It also ensures we still dump the ENGINE option to +schema.rb+ in order to avoid inconsistencies.
* | | | | | | | | | | | | Fix `count(:all)` to correctly work `distinct` with custom SELECT listRyuta Kamizono2017-12-202-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | | | | | Remove outdated comments [ci skip]Ryuta Kamizono2017-12-191-4/+0
| | | | | | | | | | | | |
* | | | | | | | | | | | | Merge pull request #31492 from prathamesh-sonpatki/rm-assert-nothing-raisedEileen M. Uchitelle2017-12-191-4/+2
|\ \ \ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | assert_nothing_raised not required here, we can assert directly for the actual result
| * | | | | | | | | | | | | assert_nothing_raised not required here, we can assert directly for the ↵Prathamesh Sonpatki2017-12-191-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | actual result
* | | | | | | | | | | | | | Quote primary key in the subselect generated by mysql2 adapterRyuta Kamizono2017-12-192-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise it will occur syntax error if primary key is a reserved word.
* | | | | | | | | | | | | | Using subselect for `delete_all` with `limit` or `offset`Ryuta Kamizono2017-12-192-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | | | | | | | | Using subselect generated by the connection adapter for `update_all` with ↵Ryuta Kamizono2017-12-191-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `offset` 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.
* | | | | | | | | | | | | | Merge pull request #31475 from ↵Matthew Draper2017-12-191-3/+8
|\ \ \ \ \ \ \ \ \ \ \ \ \ \ | |_|_|/ / / / / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | shioyama/reset_column_information_redefine_child_attribute_methods Undefine attribute methods of descendants when resetting column information
| * | | | | | | | | | | | | Add failing testChris Salzberg2017-12-171-3/+8
| |/ / / / / / / / / / / /
* | | | | | | | | | | | | Fix `test_counter_cache_with_touch_and_lock_version` failureRyuta Kamizono2017-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looks like it is failed due to datetime rounding. Related #23521. https://travis-ci.org/rails/rails/jobs/317734560#L1980-L1984