aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | | | `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
| * | | | Turn on performance based copsDillon Welch2018-07-238-31/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* | | | | Normalize time value not to be affected by summer timeRyuta Kamizono2018-07-253-10/+41
| | | | | | | | | | | | | | | | | | | | Follow up of #33358 for SQLite3.
* | | | | Merge pull request #33229 from ↵Matthew Draper2018-07-252-7/+7
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * | | | | Substitute references to task for commandAlberto Almagro2018-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This commit substitutes references to rails/rake task for rails command
| * | | | | Recommend use of rails over bin/railsAlberto Almagro2018-07-062-6/+6
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | | | | Rails guides are now served over httpsPaul McMahon2018-07-241-1/+1
| |/ / / |/| | | | | | | | | | | | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* | | | Merge pull request #30919 from seanlinsley/17622-before_save_strict_argumentsRyuta Kamizono2018-07-231-0/+27
|\ \ \ \ | | | | | | | | | | | | | | | Add strict argument checking to ActiveRecord callbacks
| * | | | add strict argument checking to ActiveRecord callbacksSean Linsley2018-07-221-0/+23
|/ / / / | | | | | | | | | | | | This ends up adding it to all save-related callbacks defined in `ActiveRecord::DefineCallbacks`, including e.g. `after_create`. Which should be fine: they didn't support `:on` in the first place.
* | | | Merge pull request #33415 from orhantoy/feature/docs-consistent-hash-syntaxGeorge Claghorn2018-07-221-8/+8
|\ \ \ \ | | | | | | | | | | [ci skip] Use consistent hash syntax in AR docs
| * | | | [ci skip] Use consistent hash syntax in AR docsOrhan Toy2018-07-221-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | The examples with `.where` uses hash w/ symbol keys so it would be more consistent to also do this with `.new`. Also from my experience the hash w/ symbol keys is more widely used with `where/new/create` etc. in ActiveRecord.
* | | | | [ci skip] Tidy up formatting of examplesOrhan Toy2018-07-221-12/+3
|/ / / / | | | | | | | | | | | | The consecutive verbatim blocks were being merged making the output look weird.
* | | | Replace permissive Mocha expectationsutilum2018-07-222-32/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Step 6 in #33162 When using Mocha like this: `ActiveRecord::Base.expects(:establish_connection).with(some_args)`, the expectations created look something like this: ``` @expectations= [#<Expectation:0x561350d968e0 expected exactly once, not yet invoked: ActiveRecord::Base.establish_connection("adapter" => "mysql2", "database" => nil) >, #<Expectation:0x561350dab8f8 allowed any number of times, not yet invoked: ActiveRecord::Base.establish_connection(any_parameters) >, #<Expectation:0x561350dc30c0 allowed any number of times, not yet invoked: ActiveRecord::Base.connection(any_parameters) >] ``` Minitest mocking (and the way we use it in `MethodCallAssertions`) expressly refuses to facilitate such permissiive expectations, insisting that all calls be specified in the actual expected order. This patch replaces such calls to `Mocha#expects` with `ActiveSupport::Testing::MethodCallAssertions` and specifies all expected calls in the epxected order.
* | | | Replace Mocha#stubs with assert_called_withutilum2018-07-221-6/+11
| | | | | | | | | | | | | | | | A correct, but not obvious use of `ActiveSupport::Testing::MethodCallAssertions`, which might also have been part of #33337 or #33391.
* | | | Fix Mocha replacement that slipped out of #33337utilum2018-07-221-11/+15
| | | |
* | | | CHANGELOG entryBrian Christian2018-07-191-0/+6
| | | |
* | | | don't impose primary key order if limit() is definedBrian Christian2018-07-191-1/+1
| | | |
* | | | tests for use of primary_key with limitBrian Christian2018-07-191-0/+15
| | | |
* | | | Merge pull request #33394 from kamipo/avoid_extra_scopingEileen M. Uchitelle2018-07-193-2/+8
|\ \ \ \ | | | | | | | | | | Avoid extra scoping in delegating to klass methods in the `scope` block
| * | | | Avoid extra scoping in delegating to klass methods in the `scope` blockRyuta Kamizono2018-07-193-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #29301, delegating to klass methods in the `scope` block would cause extra scoping by the receiver itself. The extra scoping would always override intermediate scoping like `unscoped` and caused the regression #33387. To keep the original scoping behavior, should avoid the extra scoping in the `scope` block. Fixes #33387.
* | | | | Merge pull request #33391 from utilum/method_call_assertions_instead_of_mochaRyuta Kamizono2018-07-195-98/+154
|\ \ \ \ \ | |/ / / / |/| | | | Use MethodCallAssertions instead of Mocha#expects
| * | | | Use MethodCallAssertions instead of Mocha#expectsutilum2018-07-195-98/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many calls to `Mocha#expects` preceded the introduction of `ActiveSupport::Testing::MethodCallAssertions` in 53f64c0fb, and many are simple to replace with `MethodCallAssertions`. This patch makes all these simple replacements. Step 5 in #33162
* | | | | Fix `insert_fixtures_set` to be restored original connection flagsRyuta Kamizono2018-07-193-34/+116
|/ / / / | | | | | | | | | | | | | | | | | | | | #33363 has two regressions. First one is that `insert_fixtures_set` is failed if flags is an array. Second one is that connection flags are not restored if `set_server_option` is not supported.
* | | | Revert "Short circuit the scoping delegation for `relation.all`"Ryuta Kamizono2018-07-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit eb807384c81a6e086b17a576755e992e6c4c685e. If the current scope is affected by the `unscoped` block, `all` won't be the same with `spawn`.
* | | | Merge pull request #33363 from ahorek/transaction_bugRafael França2018-07-182-5/+38
|\ \ \ \ | | | | | | | | | | use set_server_option if possible
| * | | | use set_server_option if possiblepavel2018-07-152-5/+38
| | | | |
* | | | | Merge pull request #33358 from azbshiri/summer-timeRafael França2018-07-182-2/+25
|\ \ \ \ \ | | | | | | | | | | | | Normalize the date component to 2000-01-01 automatically
| * | | | | Test DST both in local and utc timezoneAlireza Bashiri2018-07-171-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also? Updated failing test.
| * | | | | Implement change() to convert to "2001-01-01" firstSean Prashad2018-07-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | (cherry picked from commit da34d4766c33a042aeb92778a492fa810ec23001)
* | | | | | Replace some more Mocha#stub calls with Minitestutilum2018-07-173-25/+46
| | | | | | | | | | | | | | | | | | | | | | | | Missed these in preparing #33337
* | | | | | Remove unnecessary Mocha stubutilum2018-07-171-1/+0
|/ / / / / | | | | | | | | | | | | | | | Should have been removed in #33309.
* | | | | Clarify test casesbogdanvlviv2018-07-153-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove extra stub of `ActiveRecord::Base::connection` in `activerecord/test/cases/tasks/mysql_rake_test.rb`. Remove extra stub of `File::exist?` in `activerecord/test/cases/tasks/sqlite_rake_test.rb`. `ActiveRecord::Base::establish_connection` shouldn't return `true` in test cases. Related to https://github.com/rails/rails/pull/33337.
* | | | | Stub with Minitest instead of Mochautilum2018-07-156-461/+699
|/ / / / | | | | | | | | | | | | Step 4 in #33162
* | | | Merge pull request #33350 from kamipo/address_blank_lines_automaticallyRafael França2018-07-129-21/+0
|\ \ \ \ | | | | | | | | | | Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the future