HTTPS clone URL
Subversion checkout URL
Commits on Oct 2, 2015
Commits on Sep 24, 2015
In order to improve the performance of dirty checking, we're going to need to duplicate all of the `previous_` methods in Active Model. However, these methods are basically the same as their non-previous counterparts, but comparing `@original_attributes` to `@previous_original_attributes` instead of `@attributes` and `@original_attributes`. This will help reduce that duplication.
This moves a bit more of the logic required for dirty checking into the attribute objects. I had hoped to remove the `with_value_from_database` stuff, but unfortunately just calling `dup` on the attribute objects isn't enough, since the values might contain deeply nested data structures. I think this can be cleaned up further. This makes most dirty checking become lazy, and reduces the number of object allocations and amount of CPU time when assigning a value. This opens the door (but doesn't quite finish) to improving the performance of writes to a place comparable to 4.1
Commits on Jul 24, 2015
Deep down in the association internals, we're calling `destroy!` rather than `destroy` when handling things like `dependent` or autosave association callbacks. Unfortunately, due to the structure of the code (e.g. it uses callbacks for everything), it's nearly impossible to pass whether to call `destroy` or `destroy!` down to where we actually need it. As such, we have to do some legwork to handle this. Since the callbacks are what actually raise the exception, we need to rescue it in `ActiveRecord::Callbacks`, rather than `ActiveRecord::Persistence` where it matters. (As an aside, if this code wasn't so callback heavy, it would handling this would likely be as simple as changing `destroy` to call `destroy!` instead of the other way around). Since we don't want to lose the exception when `destroy!` is called (in particular, we don't want the value of the `record` field to change to the parent class), we have to do some additional legwork to hold onto it where we can use it. Again, all of this is ugly and there is definitely a better way to do this. However, barring a much more significant re-architecting for what I consider to be a reletively minor improvement, I'm willing to take this small hit to the flow of this code (begrudgingly).
Commits on Jun 10, 2015
Commits on May 28, 2015
Commits on May 2, 2015
When `AR::Base.save!` or `AR::Base.destroy!` is called and an exception is raised, the exception doesn't have any error message or has a weird message like `#<FailedBulb:0x0000000907b4b8>`. Give a better message so we can easily understand why it's failing to save/destroy.
Commits on Apr 28, 2015
Commits on Apr 27, 2015
Commits on Apr 19, 2015
This will avoid the indirection of having calling id since we already know which is the primary key column. Also this will make explicit the behavior since it is not clear that id gets the right primary key value and not just the value of the "id" column.
Fixes #19776 change test variable names and use more verbose on method less verbose use _read_attribute instead of send
Commits on Apr 8, 2015
Commits on Mar 2, 2015
directly calling `sync_with_transaction_state` is not fast, so if we call it once, we can improve the performance of the `persisted?` method. This is important because every call to `url_for(model)` will call `persisted?`, so we want that to be fast. Here is the benchmark: ```ruby require 'active_record' ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" ActiveRecord::Base.connection.instance_eval do create_table(:articles) end class Article < ActiveRecord::Base; end article = Article.new.tap(&:save!) Benchmark.ips do |x| x.report("persisted?") do article.persisted? end end ``` Before this patch: ``` $ bundle exec ruby -rbenchmark/ips persisted.rb Calculating ------------------------------------- persisted? 3.333k i/100ms ------------------------------------------------- persisted? 51.037k (± 8.2%) i/s - 253.308k ``` After: ``` $ bundle exec ruby -rbenchmark/ips persisted.rb Calculating ------------------------------------- persisted? 7.172k i/100ms ------------------------------------------------- persisted? 120.730k (± 5.1%) i/s - 602.448k ```
Commits on Feb 20, 2015
Commits on Feb 18, 2015
Commits on Feb 4, 2015
When ```becomes``` changes @attributes it should also change @changed_attributes. Otherwise we'll experience a kind of split head situation where attributes are coming from ```self```, but changed_attributes is coming from ```klass.new```. This affects the inheritance_colmn as it's changed by new for example. Fixes #16881
Commits on Feb 1, 2015
Commits on Jan 23, 2015
Commits on Jan 18, 2015
- This is based on #18400 but tackling same issue with update_attribute method instead of update method.
Commits on Jan 14, 2015
Commits on Jan 2, 2015
Before this commit, returning `false` in an ActiveRecord `before_` callback such as `before_create` would halt the callback chain. After this commit, the behavior is deprecated: will still work until the next release of Rails but will also display a deprecation warning. The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
Commits on Dec 29, 2014
Commits on Dec 28, 2014
…g timestamps. [#18202]
Commits on Dec 24, 2014
Commits on Dec 3, 2014
Commits on Nov 28, 2014
Since 3e30c5d, it started ignoring the given error message. This commit changes the behavior of AR::RecordNotSaved#initialize so that it no longer loses the given error message.
Commits on Nov 26, 2014
This allows these exceptions to be handled generically in conjunction with RecordInvalid.
Commits on Nov 17, 2014
Oh hey, we got to remove some code because of that!
Commits on Nov 14, 2014
This reverts commit 8fee923. Conflicts: activerecord/lib/active_record/attribute_set/builder.rb This solution sucks, and is hard to actually apply across the board. Going to try other solutions
Commits on Nov 7, 2014
Currently, there is no messages which get printed out. Convoluted system may have hooks that create other objects in which case we only fail with no messages. This commit changes this information allowing you to know which object is the one that actually raised the error.
Commits on Nov 5, 2014
We introduced a performance hit by adding an additional iteration through a model's attributes on creation. We don't actually need the values from `Result` to be a hash, we can separate the columns and values and zip them up ourself during the iteration that we have to do.
Commits on Sep 28, 2014
…Associations and Aggregations modules, respectively. This includes replacing the `association_cache` accessor with a more limited `association_cached?` accessor and making `clear_association_cache` and `clear_aggregation_cache` private.