aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | Handle aliased attributes in AR::Relation#select, #order, etc.Tsutomu Kuroda2014-01-291-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this we can write `Model#select(:aliased)`, `Model#order(:aliased)`, `Model#reoder(aliased: :desc)`, etc. Supplementary work to 54122067acaad39b277a5363c6d11d6804c7bf6b.
| * | | | | Merge pull request #13838 from vipulnsward/13197-fix-has-one-documentationDamien Mathieu2014-01-281-1/+2
| |\ \ \ \ \ | | | | | | | | | | | | | | Add docs about behaviour of replacing a has_one associate object.
| | * | | | | Add docs about behaviour of replacing a has_one associate object, that the ↵Vipul A M2014-01-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | previous one is deleted even if the new one doesn't get persisted to database. Fixes #13197 . [ci skip]
| * | | | | | Display value when raising due to unscope() issuesWashington Luiz2014-01-271-1/+1
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hopefully make it easier to debug errors. e.g Before: RuntimeError: unscope(where: "deleted_at") failed: unscoping String is unimplemented. After: RuntimeError: unscope(where: "deleted_at") failed: unscoping String "'t'='t'" is unimplemented.
| * | | | | Merge pull request #13785 from kuldeepaggarwal/fix-find_with_multiple_idsYves Senn2014-01-241-2/+2
| |\ \ \ \ \ | | | | | | | | | | | | | | Fix `ActiveRecord::RecordNotFound` error message with custom primary key
| | * | | | | Fix `ActiveRecord::RecordNotFound` error message with custom primary keyKuldeep Aggarwal2014-01-251-2/+2
| | | | | | |
| * | | | | | Merge pull request #13799 from kbrock/better_dirtyJeremy Kemper2014-01-227-18/+49
| |\ \ \ \ \ \ | | |/ / / / / | |/| | | | | Better ActiveRecord hierarchy for Dirty and others
| | * | | | | Move changed_attributes into dirty.rbKeenan Brock2014-01-226-16/+47
| | | | | | | | | | | | | | | | | | | | | Move serialization dirty into serialization.rb
| | * | | | | put core at the beginning so other classes can modify the behaviorKeenan Brock2014-01-222-2/+2
| | | | | | |
| * | | | | | Merge pull request #13791 from kei-s/remove_duplicate_mergeCarlos Antonio da Silva2014-01-221-1/+0
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | Remove duplicate merge
| | * | | | | | Remove duplicate mergekei2014-01-221-1/+0
| | | | | | | |
| * | | | | | | Make CollectionProxy#reset return selfRafael Mendonça França2014-01-221-1/+2
| | | | | | | |
| * | | | | | | Calling reset on a collection association should unload the assocationKelsey Schlarman2014-01-211-0/+21
| |/ / / / / / | | | | | | | | | | | | | | | | | | | | | Need to define #reset on CollectionProxy.
| * | | | | | Ensure AR #second, #third, etc. finders work through associationsJason Meller2014-01-213-13/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes two regressions introduced in cafe31a078 where newly created finder methods #second, #third, #forth, and #fifth caused a NoMethodError error on reload associations and where we were pulling the wrong element out of cached associations. Examples: some_book.authors.reload.second # Before # => NoMethodError: undefined method 'first' for nil:NilClass # After # => #<Author id: 2, name: "Sally Second", ...> some_book.first.authors.first some_book.first.authors.second # Before # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 1, name: "Freddy First", ...> # After # => #<Author id: 1, name: "Freddy First", ...> # => #<Author id: 2, name: "Sally Second", ...> Fixes #13783.
| * | | | | | Merge pull request #13776 from rails/dirty-enumRafael Mendonça França2014-01-212-4/+36
| |\ \ \ \ \ \ | | |/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the Dirty API with the Enum feature correctly. Conflicts: activerecord/CHANGELOG.md
| | * | | | | Use string as keysRafael Mendonça França2014-01-211-2/+2
| | | | | | |
| | * | | | | Store the enum values in the DEFINED_ENUM constantRafael Mendonça França2014-01-211-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will make simpler to compare if the values changed in the save_changed_attribute method.
| | * | | | | Add more tests for the dirty feature for enumsRafael Mendonça França2014-01-212-8/+19
| | | | | | |
| | * | | | | Make enum feature work with dirty methodsRafael Mendonça França2014-01-211-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To make this possible we have to override the save_changed_attribute hook.
| | * | | | | Extract all attribute changed work to its own methodRafael Mendonça França2014-01-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will make easier to hook on this feature to customize the behavior
| * | | | | | add missing information for `id` field when used with `select` [ci skip]Kuldeep Aggarwal2014-01-221-1/+1
| | | | | | |
| * | | | | | `has_one` and `belongs_to` accessors don't add ORDER BY to the queries anymore.Rafael Mendonça França2014-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent results among different database engines. But for singular associations this behavior is not needed since we will have one record to return. As this ORDER BY option can lead some performance issues we are removing it for singular associations accessors. Fixes #12623.
| * | | | | | prepend table name for `Relation#select` columns.Yves Senn2014-01-211-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug where `select(:id)` combined with `joins()` raised: ``` ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: id: SELECT id, authors.author_address_id FROM "posts" INNER JOIN "authors" ON "authors"."id" = "posts"."author_id" ORDER BY posts.id LIMIT 3 ``` The `select_values` are still String and Symbols because other parts (mainly calculations.rb) rely on that fact. /cc @tenderlove
| * | | | | | Merge pull request #9969 from divineforest/fix-find-in-batchesYves Senn2014-01-211-5/+2
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | Fail early with "Primary key not included in the custom select clause" i...
| | * | | | | | Fail early with "Primary key not included in the custom select clause" in ↵Alexander Balashov2014-01-211-5/+2
| | |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | find_in_batches Before this patch find_in_batches raises this error only on second iteration. So you will know about the problem only when you get the batch size threshold.
| * / / / / / Remove missed usage of @first variableCarlos Antonio da Silva2014-01-211-1/+1
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the introduction of `#second` method and friends, we added an offsets hash which replaced the @first variable, so removing it from the reset method to avoid creating an unused variable now. Introduced in bc625080308e4853ae3036f2ad74fe3826e463ef.
| * | | | | Remove unneded argumentRafael Mendonça França2014-01-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This variable is internal and should not be exposed to end users
| * | | | | Ensure #second acts like #first AR finderJason Meller2014-01-203-8/+91
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit bring the famous ordinal Array instance methods defined in ActiveSupport into ActiveRecord as fully-fledged finders. These finders ensure a default ascending order of the table's primary key, and utilize the OFFSET SQL verb to locate the user's desired record. If an offset is defined in the query, calling #second adds to the offset to get the actual desired record. Fixes #13743.
| * | | | Restore ActiveRecord states after a rollback for models w/o callbacksGodfrey Chan2014-01-182-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression (#13744) that was caused by 67d8bb9. In 67d8bb9, we introduced lazy rollback for records, such that the record's internal states and attributes are not restored immediately after a transaction rollback, but deferred until they are first accessed. This optimization is only performed when the model does not have any transactional callbacks (e.g. `after_commit` and `after_create`). Unfortunately, the models used to test the affected codepaths all comes with some sort of transactional callbacks. Therefore this codepath remains largely untested until now and as a result there are a few issues in the implementation that remains hidden until now. First, the `sync_with_transaction_state` (or more accurately, `update_attributes_from_transaction_state`) would perform the synchronization prematurely before a transaction is finalized (i.e. comitted or rolled back). As a result, when the actuall rollback happens, the record will incorrectly assumes that its internal states match the transaction state, and neglect to perform the restore. Second, `update_attributes_from_transaction_state` calls `committed!` in some cases. This in turns checks for the `destroyed?` state which also requires synchronization with the transaction stae, which causes an infnite recurrsion. This fix works by deferring the synchronization until the transaction has been finalized (addressing the first point), and also unrolled the `committed!` and `rolledback!` logic in-place (addressing the second point). It should be noted that the primary purpose of the `committed!` and `rolledback!` methods are to trigger the relevant transactional callbacks. Since this code path is only entered when there are no transactional callbacks on the model, this shouldn't be necessary. By unrolling the method calls, the intention here (to restore the states when necessary) becomes more clear.
| * | | | fix exception translationAaron Patterson2014-01-172-3/+4
| | | | |
| * | | | translate exceptions on prepared statement failureAaron Patterson2014-01-172-6/+13
| | | | |
* | | | | fix the method signatureAaron Patterson2014-01-171-1/+1
| | | | |
* | | | | run the damn tests @tenderloveAaron Patterson2014-01-172-2/+2
| | | | |
* | | | | Merge branch 'adequaterecord' of github.com:rails/rails into adequaterecordAaron Patterson2014-01-171-1/+0
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | * 'adequaterecord' of github.com:rails/rails: Remove outdated comment.
| * | | | | Remove outdated comment.Rafael Mendonça França2014-01-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code duplication was removed and this comment is pointing to the wrong line. [ci skip]
* | | | | | oops!Aaron Patterson2014-01-171-1/+1
|/ / / / /
* | | | | don't cache the connection (because we don't need to)Aaron Patterson2014-01-171-8/+7
| | | | |
* | | | | Revert "adding set_binds"Aaron Patterson2014-01-171-8/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit 474ebc55bd13ad58626a49dfc44c8e6407813935.
* | | | | remove dead codeAaron Patterson2014-01-172-8/+1
| | | | |
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-01-171-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Fix eager load of Serializers on Active Model Consistence in the block style Remove warnings on Ruby 2.1 Only some dynamic finders are deprecated. clean up security guide: his => their [ci skip] Remove warning Extract a method to simplify setup code Use minitest's skip rather than conditionals + early returns Move AR test classes inside the test case Do not set up a variable used only in two tests No need for instance vars on single tests Cleanup duplicated setup of callbacks in transactions tests No need to use #send with public methods Update deprecation warning to give more information about caller Update changelog Avoid scanning multiple render calls as a single match. Improve ERB dependency detection.
| * | | | Update deprecation warning to give more information about callerT.J. Schuck2014-01-161-2/+2
| | | | |
* | | | | change query strategy based on adapterAaron Patterson2014-01-163-4/+51
| | | | |
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-01-161-6/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Make AR::Base#touch fire the after_commit and after_rollback callbacks Fix test for cache_key + touched Revert "methods are defined right after the module_eval, so we don't need to do" Revert "Don't remove trailing slash from PATH_INFO for mounted apps" Add failing test for #13369 reset column information after fiddling with `Encoding.default_internal` we have `with_env_tz` as global test helper. Remove duplicate. isolate class attribute assignment in `migration_test.rb` use `teardown` for cleanup, not `setup`. tests without transactional fixtures need to cleanup afterwards. no need to `return skip` in tests. `skip` is enough. methods are defined right after the module_eval, so we don't need to do any line number maths Get rid of unused TransactionError constant Avoid converting :on option to array twice when defining commit/rollback callbacks Unify changelog entries about single quotes [ci skip] Use single quotes in generated files
| * | | | Make AR::Base#touch fire the after_commit and after_rollback callbacksHarry Brundage2014-01-161-0/+4
| | | | |
| * | | | Get rid of unused TransactionError constantCarlos Antonio da Silva2014-01-151-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been added 9 years ago in a677da209b16f43198b3485dda89dce862fb9bfb, and removed 6 years ago in 38f8252e2d0a109d1b833d6b289cd989e7bfffe4.
| * | | | Avoid converting :on option to array twice when defining commit/rollback ↵Carlos Antonio da Silva2014-01-151-3/+2
| | | | | | | | | | | | | | | | | | | | callbacks
* | | | | use a params hash so we know what bind parameters are usedAaron Patterson2014-01-152-10/+49
| | | | |
* | | | | fix exception translationAaron Patterson2014-01-142-3/+4
| | | | |
* | | | | translate exceptions on prepared statement failureAaron Patterson2014-01-142-6/+13
| | | | |
* | | | | reorder bind indexes if joins produced bind valuesAaron Patterson2014-01-141-0/+9
| | | | |