aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-081-0/+1
|\ | | | | Prevent destructive action on production database
| * Prevent destructive action on production databaseschneems2016-01-071-0/+1
| | | | | | | | | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* | Update copyright notices to 2016 [ci skip]Rashmi Yadav2015-12-311-1/+1
|/
* Add #cache_key to ActiveRecord::Relation.Alberto F. Capel2015-07-201-0/+1
|
* Autoload ActiveRecord::RecordInvalidRafael Mendonça França2015-06-181-0/+1
| | | | Fixes #20626
* Batch touch parent recordsArthur Neves2015-04-081-0/+1
| | | | | | | | | | [fixes #18606] Make belongs_to use touch over touch_later when running the callbacks. Add more tests and small method rename Thanks Jeremy for the feedback.
* Attempt to provide backwards compatible YAML deserializationSean Griffin2015-03-101-0/+1
| | | | | | | | | | | | | | | | | | I should have done this in the first place. We are now serializing an explicit version so we can make more careful changes in the future. This will load Active Record objects which were serialized in Rails 4.1. There will be bugs, as YAML serialization was at least partially broken back then. There will also be edge cases that we might not be able to handle, especially if the type of a column has changed. In addition, we're passing this as `from_database`, since that is required for serialized columns at minimum. All other types were serializing the cast value. At a glance, there should be no types for which this is a problem. Finally, dirty checking information will be lost on records serialized in 4.1, so no columns will be marked as changed.
* Add `ActiveRecord::Base.suppress`Michael Ryan2015-02-181-0/+1
|
* Add has_secure_token to Active Recordrobertomiranda2015-01-041-0/+1
| | | | | | Update SecureToken Docs Add Changelog entry for has_secure_token [ci skip]
* Update copyright notices to 2015 [ci skip]Arun Agrawal2014-12-311-1/+1
|
* Remove `klass` and `arel_table` as a dependency of `PredicateBuilder`Sean Griffin2014-12-261-0/+1
| | | | | | | | | | | | | | | This class cares far too much about the internals of other parts of Active Record. This is an attempt to break out a meaningful object which represents the needs of the predicate builder. I'm not fully satisfied with the name, but the general concept is an object which represents a table, the associations to/from that table, and the types associated with it. Many of these exist at the `ActiveRecord::Base` class level, not as properties of the table itself, hence the need for another object. Currently it provides these by holding a reference to the class, but that will likely change in the future. This allows the predicate builder to remain wholy concerned with building predicates. /cc @mrgilman
* Revert "Revert "Merge pull request #16059 from jenncoop/json-serialized-attr""Godfrey Chan2014-07-151-0/+1
| | | | | | | This reverts commit 6f3c64eeb1dc8288dae49f114aaf619adc7dcb7f. Conflicts: activerecord/CHANGELOG.md
* Revert "Merge pull request #16059 from jenncoop/json-serialized-attr"Godfrey Chan2014-07-051-1/+0
| | | | | | This reverts commit a03097759bd7103bb9db253e7ba095f011453f75. This needs more work before it would work correctly on master.
* Merge pull request #16059 from jenncoop/json-serialized-attrGodfrey Chan2014-07-051-0/+1
| | | | | | | | Fixed issue with ActiveRecord serialize object as JSON Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/attribute_methods/serialization.rb
* Move behavior of `read_attribute` to `AttributeSet`Sean Griffin2014-06-251-1/+1
| | | | | | | | | | | | | | | Moved `Builder` to its own file, as it started looking very weird once I added private methods to the `AttributeSet` class and the `Builder` class started to grow. Would like to refactor `fetch_value` to change to ```ruby self[name].value(&block) ``` But that requires the attributes to know about their name, which they currently do not.
* Introduce an object to aid in creation and management of `@attributes`Sean Griffin2014-06-191-0/+1
| | | | | Mostly delegation to start, but we can start moving a lot of behavior in bulk to this object.
* Introduce an Attribute object to handle the type casting danceSean Griffin2014-06-131-0/+1
| | | | | | | | | | | | | | | There's a lot more that can be moved to these, but this felt like a good place to introduce the object. Plans are: - Remove all knowledge of type casting from the columns, beyond a reference to the cast_type - Move type_cast_for_database to these objects - Potentially make them mutable, introduce a state machine, and have dirty checking handled here as well - Move `attribute`, `decorate_attribute`, and anything else that modifies types to mess with this object, not the columns hash - Introduce a collection object to manage these, reduce allocations, and not require serializing the types
* update copyright notices to 2014. [ci skip]Vipul A M2014-01-011-1/+1
|
* add #no_touching on ActiveRecord modelsDamien Mathieu2013-11-131-0/+1
|
* Added ActiveRecord::Base#enum for declaring enum attributes where the values ↵David Heinemeier Hansson2013-11-021-0/+1
| | | | map to integers in the database, but can be queried by name
* Removes unused code related to DatabaseTasks.kennyj2013-09-161-4/+0
|
* deprecated `ActiveRecord::TestCase` is no longer public.Yves Senn2013-07-021-1/+0
| | | | /cc @tenderlove
* Remove depreacted findersŁukasz Strzałkowski2013-06-281-1/+0
| | | | They were deprecated in 4.0, planned to remove in 4.1
* Set the inverse when association queries are refinedJon Leighton2013-05-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Suppose Man has_many interests, and inverse_of is used. Man.first.interests.first.man will correctly execute two queries, avoiding the need for a third query when Interest#man is called. This is because CollectionAssociation#first calls set_inverse_instance. However Man.first.interests.where("1=1").first.man will execute three queries, even though this is obviously a subset of the records in the association. This is because calling where("1=1") spawns a new Relation object from the CollectionProxy object, and the Relation has no knowledge of the association, so it cannot set the inverse instance. This commit solves the problem by making relations spawned from CollectionProxies return a new Relation subclass called AssociationRelation, which does know about associations. Records loaded from this class will get the inverse instance set properly. Fixes #5717. Live commit from La Conf! :sparkles:
* Merge pull request #10152 from Noemj/statement_cacheRafael Mendonça França2013-04-101-0/+1
|\ | | | | | | | | | | | | Statement cache Conflicts: activerecord/CHANGELOG.md
| * Added statement cacheNoemj2013-04-101-0/+1
| |
* | Created a runtime registry for thread local variables in active record.wangjohn2013-04-091-0/+1
| |
* | Sort modules in alphabetical order.Shunsuke Osa2013-04-051-2/+2
| |
* | Extract Oracle database tasks.kennyj2013-04-031-0/+1
| |
* | Extract Sqlserver database tasks.kennyj2013-04-031-0/+1
| |
* | Extract Firebird database tasks.kennyj2013-04-031-0/+2
|/
* Updated copyright notices for 2013Andrew Nesbitt2012-12-311-1/+1
|
* Remove observers and sweepersRafael Mendonça França2012-11-281-1/+0
| | | | | | | | They was extracted from a plugin. See https://github.com/rails/rails-observers [Rafael Mendonça França + Steve Klabnik]
* Remove ActiveRecord::ModelJon Leighton2012-10-261-1/+0
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* Extract ActiveRecord::SessionStore from RailsPrem Sichanugrist2012-08-241-11/+0
| | | | | This functionality will be available from gem `active_record-session_store` instead.
* Get rid of config.preload_frameworks in favor of config.eager_load_namespacesJosé Valim2012-08-211-0/+9
| | | | | | | The new option allows any Ruby namespace to be registered and set up for eager load. We are effectively exposing the structure existing in Rails since v3.0 for all developers in order to make their applications thread-safe and CoW friendly.
* Renaming active_record_deprecated_finders to activerecord-deprecated_findersJon Leighton2012-08-171-1/+1
| | | | For consistency with the other AR extension plugins we are creating.
* Don't eager load all thisSantiago Pastorino2012-08-031-32/+33
| | | | | Some are loaded from Base which is loaded when a model inherits from it and some others are used in rake tasks
* defines a private require-hub active_support/railsXavier Noria2012-08-021-0/+1
| | | | | | | | This is a private place to put those AS features that are used by every component. Nowadays we cherry-pick individual files wherever they are used, but that it is not worth the effort for stuff that is going to be loaded for sure sooner or later, like blank?, autoload, concern, etc.
* removes the AR session store from eager loaded code [fixes #7160]Xavier Noria2012-07-291-1/+10
| | | | | See the comment in the file activerecord/lib/active_record.rb added by this patch for the rationale.
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-0/+1
| | | | | | | | | | | This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-181-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* db:create for PostgreSQL pulled out into a class.Pat Allan2012-06-171-0/+2
|
* db:create for MySQL now much cleaner.Pat Allan2012-06-171-0/+2
|
* A beginning of sorts.Pat Allan2012-06-171-0/+6
| | | | Minimal implementation that supports db:create SQLite replacement
* SchemaMigration should be loaded lazily.kennyj2012-05-291-0/+1
|
* Fix the buildSantiago Pastorino2012-05-221-1/+0
|
* require active_support/lazy_load_hooks where is neededSantiago Pastorino2012-05-221-0/+1
|
* Lazy load I18nSantiago Pastorino2012-05-111-2/+3
|
* clean up implementation of dynamic methods. use method compilation etc.Jon Leighton2012-05-041-2/+0
|