aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #33162 from utilum/stop_using_mochaKasper Timm Hansen2018-08-227-53/+88
|\ | | | | Stop using Mocha
| * Add method_call_assertions and use them instead of Mochautilum2018-08-134-36/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Six Mocha calls prove quite resistant to Minitestification. For example, if we replace ``` ActiveRecord::Associations::HasManyAssociation .any_instance .expects(:reader) .never ``` with `assert_not_called`, Minitest wisely raises ``` NameError: undefined method `reader' for class `ActiveRecord::Associations::HasManyAssociation' ``` as `:reader` comes from a deeply embedded abstract class, `ActiveRecord::Associations::CollectionAssociation`. This patch tackles this difficulty by adding `ActiveSupport::Testing::MethodCallAsserts#assert_called_on_instance_of` which injects a stubbed method into `klass`, and verifies the number of times it is called, similar to `assert_called`. It also adds a convenience method, `assert_not_called_on_instance_of`, mirroring `assert_not_called`. It uses the new method_call_assertions to replace the remaining Mocha calls in `ActiveRecord` tests. [utilum + bogdanvlviv + kspath]
| * Stub with Minitest and test with MethodCallAssertionsutilum2018-08-133-17/+30
| |
* | Partly revert unused accessorRyuta Kamizono2018-08-231-8/+1
| | | | | | | | This was introduced at 24f6bf0d96b58f2b2ef6a886c93d35cf8ce4f293.
* | Add database configuration to disable advisory locks.Guo Xiang Tan2018-08-227-3/+65
| | | | | | | | https://github.com/rails/rails/issues/31190
* | Fix merging relation that order including `?`Ryuta Kamizono2018-08-212-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `Relation::Merger` has a problem that order values would be merged as nested array. That was caused an issue #33664 since if array value is passed to `order` and first element in the array includes `?`, the array is regarded as a prepared statement and bind variables. https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html#method-i-sanitize_sql_for_order Just merging that as splat args like other values would fix the issue. Fixes #33664.
* | Merge pull request #33652 from tgxworld/improve_tests_pool_configRyuta Kamizono2018-08-202-5/+50
|\ \ | | | | | | Improve tests for ActiveRecord::ConnectionAdapters::ConnectionPool co…
| * | Speed up slow ConnectionPool test case.Guo Xiang Tan2018-08-201-11/+19
| | |
| * | Improve tests for ActiveRecord::ConnectionAdapters::ConnectionPool ↵Guo Xiang Tan2018-08-192-2/+39
| | | | | | | | | | | | configurations.
* | | Merge pull request #33657 from jychen7/fix-test-association-enumRyuta Kamizono2018-08-201-0/+3
|\ \ \ | | | | | | | | Improve test case to test enum correctly
| * | | Improve test case to test enum correctlyRich2018-08-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | without define the enum in class “SpecialBook”, any string status will be casted to integer 0. Then the test have no meaning. [Rich Chen]
* | | | SQLite3: Fix rename reference column not to lose foreign key constraintRyuta Kamizono2018-08-202-11/+31
|/ / / | | | | | | | | | Fixes #33520.
* / / Address intermittent CI failure due to non-determined sort orderRyuta Kamizono2018-08-191-1/+1
|/ / | | | | | | https://travis-ci.org/rails/rails/jobs/417783260#L1173-L1179
* | Ensure `foreign_keys` assertions after alter tableRyuta Kamizono2018-08-191-1/+5
| | | | | | | | | | If `foreign_keys` is fetched before alter table, it couldn't notice whether foreign keys are broken or not after alter table.
* | Enable Style/ParenthesesAroundCondition copRyuta Kamizono2018-08-191-1/+1
| | | | | | | | To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
* | Merge pull request #33585 from yahonda/diag33520Ryuta Kamizono2018-08-163-1/+26
|\ \ | | | | | | | | | SQLite3 adapter `alter_table` method restores foreign keys
| * | SQLite3 adapter `alter_table` method restores foreign keysYasuo Honda2018-08-113-1/+26
| | | | | | | | | | | | Related to #33520
* | | Merge pull request #33603 from kamipo/fix_numericality_validatorRyuta Kamizono2018-08-163-2/+26
|\ \ \ | | | | | | | | Fix numericality validator not to be affected by custom getter
| * | | Fix numericality validator not to be affected by custom getterRyuta Kamizono2018-08-133-2/+26
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since fe9547b6, numericality validator would parse raw value only when a value came from user to work type casting to a value from database. But that was caused a regression that the validator would work against getter value instead of parsed raw value, a getter is sometimes customized by people. #33550 There we never guarantees that the value before type cast was going to the used in this validation (actually here is only place that getter value might not be used), but we should not change the behavior unless there is some particular reason. The purpose of fe9547b6 is to work type casting to a value from database. We could achieve the purpose by using `read_attribute`, without using getter value. Fixes #33550.
* | | Merge pull request #33499 from lsylvester/caller-ignore-pathsKasper Timm Hansen2018-08-152-9/+9
|\ \ \ | | | | | | | | use BacktraceCleaner for ActiveRecord verbose logging
| * | | Use backtrace cleaner to clean up backtrace for verbose query logsLachlan Sylvester2018-08-142-9/+9
| |/ /
* | | Fix bulk change table ignores comment option on PostgreSQL.Yoshiyuki Kinjo2018-08-152-3/+16
| | |
* | | Follow up #33530bogdanvlviv2018-08-153-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Move changelog entry of #33530 up in order to preserve the chronology since we always add new entries on the top of a changelog file. - Clarify the changelog entry - Clarify the docs of remove_foreign_key - Ensure reversible of `remove_foreign_key` with `:primary_key` and `:to_table` options.
* | | Merge pull request #33530 from jychen7/33515-invert-remove-foreign-keyRichard Schneeman2018-08-144-4/+36
|\ \ \ | | | | | | | | 33515 invert remove foreign key support "to_table"
| * | | Allow `to_table` in `invert_remove_foreign_key`Rich2018-08-144-4/+36
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
* / / Use `Array#extract!` where possiblebogdanvlviv2018-08-142-8/+12
|/ /
* / Use strings instead of symbols on calls to decorate_matching_attribute_typesDillon Welch2018-08-102-2/+2
|/ | | | | | The first thing this method does is run on the argument. This change passes in a string so we don't allocate a bunch of unnecessary extra strings by calling to_s on a symbol over and over.
* Fix a wrong correctionKazuhiro Sera2018-08-081-1/+1
|
* Fix the obvious typos detected by github.com/client9/misspellKazuhiro Sera2018-08-085-16/+16
|
* Merge pull request #33454 from azbshiri/extend-affects-nested-attributesRichard Schneeman2018-08-043-2/+20
|\ | | | | Call build when extend with nested attributes defined
| * Call build when extend with nested attributes definedAlireza Bashiri2018-08-023-2/+20
| | | | | | | | | | | | | | | | What? From now on when `accepts_nested_attributes_for` defined and `extend` option added the overwritten `build` method being called. [Alireza Bashiri, Martins Polakovs]
* | Merge pull request #33511 from ↵Richard Schneeman2018-08-043-4/+4
|\ \ | | | | | | | | | | | | albertoalmagro/change-references-from-rake-to-rails-command Change references from Rake task to Rails command
| * | [ci skip] Change references from Rake task to Rails commandAlberto Almagro2018-08-013-4/+4
| | | | | | | | | | | | | | | This commit follows the path we started at commit #ea4f0e2 and continued at PR #33229.
* | | `retrieve_connection_pool` return a pool, not a connectionRyuta Kamizono2018-08-031-2/+2
| |/ |/|
* | don't establish connection test_database since it gets established in ↵Britni Alexander2018-08-011-1/+0
|/ | | | load_schema
* use load_schema instead of migrate for parallel testingBritni Alexander2018-07-312-6/+9
|
* Revert "Merge pull request #24131 from brchristian/limit_and_primary_key"Ryuta Kamizono2018-08-013-22/+1
| | | | | | | | | | This reverts commit d162188dd662a7d9f62ba8431474f50bc35e3e93, reversing changes made to 3576782888c307e3e192c44e332b957cd1174128. Reason: #24131 conflicts the #5153's default order contract, it means that existing apps would be broken by that change. We don't want to break existing apps without a deprecation cycle.
* Add test case for the #5153's default order contractRyuta Kamizono2018-08-011-0/+13
|
* Avoid extra scoping when using `Relation#update`Ryuta Kamizono2018-07-313-3/+9
| | | | | | | | | | | | | | Since 9ac7dd4, class level `update`, `destroy`, and `delete` were placed in the `Persistence` module as class methods. But `Relation#update` without passing ids which was introduced at #11898 is not a class method, and it was caused the extra scoping regression #33470. I moved the relation method back into the `Relation` to fix the regression. Fixes #33470.
* MySQL: Raise ActiveRecord::InvalidForeignKey for foreign-key constraint ↵George Claghorn2018-07-303-7/+20
| | | | violations on delete
* Extract `Relation#bind_attribute` for internal useRyuta Kamizono2018-07-302-8/+11
| | | | To make it easier to construct boundable predicate.
* Extract `Relation#update_counters` for internal useRyuta Kamizono2018-07-304-34/+27
| | | | | | The target object for counter cache is not always determined by the primary key value on the model. I'd like to extract `update_couters` onto the `Relation` for the internal use.
* Fix TypeError: no implicit conversion of Arel::Attributes::Attribute into StringBart de Water2018-07-281-1/+1
|
* Fix test failures due to Performance/RegexpMatch correctionBart de Water2018-07-281-1/+3
| | | | `5 =~ /\d/` returns nil, but Integer doesn't have a `match?` method.
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-282-2/+2
| | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* Don't expose configuration for a test.Kasper Timm Hansen2018-07-282-23/+12
| | | | Clean up some concepts in the code while we're here.
* Avoid logging ActiveRecord::LogSubscriber as the query source when the ↵lsylvester2018-07-282-12/+22
| | | | source is ignored (#33455)
* PostgreSQL 10 new relkind for partitioned tables (#31336)Yannick Schutz2018-07-272-2/+24
| | | | | | | | | | | | | | | | | | | | | | | * PostgreSQL 10 new relkind for partitioned tables Starting with PostgreSQL 10, we can now have partitioned tables natively * Add comment * Remove extra space * Add test for partition table in postgreSQL10 * Select 'p' for "BASE TABLE" and add a test case to support PostgreSQL 10 partition tables * Address RuboCop offense * Addressed incorrect `postgresql_version` Fixes #33008. [Yannick Schutz & Yasuo Honda & Ryuta Kamizono]
* Remove Rubocop's comments from Rails code basebogdanvlviv2018-07-261-1/+1
| | | | | | | | | | PR#32381 added Rubocop's comments to some tests files in order to exclude `Performance/RedundantMerge`. Turn off `Performance` cops for tests files via `Exclude` in `.rubocop.yml`. Context https://github.com/rails/rails/pull/32381#discussion_r205212331
* Merge pull request #32381 from q-centrix/update-codeclimate-configsRichard Schneeman2018-07-258-31/+19
|\ | | | | Turn on performance based cops