- 30 3月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
Fixes #19568
-
- 27 3月, 2015 1 次提交
-
-
由 Jon Atack 提交于
- ‘dection’ -> ‘detection’ - ‘exceeds threshold’ -> ‘exceeds the threshold’ - Other minor improvements.
-
- 26 3月, 2015 1 次提交
-
-
由 Jason Nochlin 提交于
When set to an integer, a warning will be logged whenever a result set larger than the specified size is returned by a query. Fixes #16463 The warning is outputed a module which is prepended in an initializer, so there will be no performance impact if `config.active_record.warn_on_records_fetched_greater_than` is not set.
-
- 22 3月, 2015 1 次提交
-
-
由 Guo Xiang Tan 提交于
This reverts commit 796cab45.
-
- 18 3月, 2015 1 次提交
-
-
由 Ryan Wallace 提交于
Fixes db:structure:dump when using schema_search_path and PostgreSQL extensions. Closes #17157.
-
- 12 3月, 2015 1 次提交
-
-
由 Ben Woosley 提交于
Instead use .scope_attributes? consistently in ActiveRecord to check whether there are attributes currently associated with the scope. Move the implementation of .scope_attributes? and .scope_attributes to ActiveRecord::Scoping because they don't particularly have to do specifically with Named scopes and their only dependency, in the case of .scope_attributes?, and only caller, in the case of .scope_attributes is contained in Scoping.
-
- 11 3月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
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.
-
- 03 3月, 2015 2 次提交
-
-
由 Aaron Patterson 提交于
This reverts commit 393e65b4 and ec51c3fe We don't want the records to hold hard references to transactions because they point at records that have callbacks.
-
由 Aaron Patterson 提交于
this way we don't have to mutate a state object, we can just change the state of the txn
-
- 02 3月, 2015 3 次提交
-
-
由 Arthur Neves 提交于
-
由 Arthur Neves 提交于
As far as I can tell nobody is setting this variable.
-
由 Aaron Patterson 提交于
`@reflects_state[depth+1]` will always be nil because we haven't made a method call that would make it true yet.
-
- 25 2月, 2015 1 次提交
-
-
由 Arthur Neves 提交于
[fixes #18903]
-
- 22 2月, 2015 1 次提交
-
-
由 Josef Šimánek 提交于
Deprecate `required` option in favor of `optional` for belongs_to.
-
- 06 2月, 2015 2 次提交
-
-
由 Rafael Mendonça França 提交于
They are implementation details
-
由 Rafael Mendonça França 提交于
Deprecated finders are not supported anymore
-
- 02 2月, 2015 2 次提交
-
-
由 Will Bryant 提交于
Fix Issue #15549, unbounded memory growth when saving records that have any after_create callbacks (or any associations, which makes after_create callbacks for you)
-
由 Aaron Patterson 提交于
-
- 01 2月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
It's finally finished!!!!!!! The reason the Attributes API was kept private in 4.2 was due to some publicly visible implementation details. It was previously implemented by overloading `columns` and `columns_hash`, to make them return column objects which were modified with the attribute information. This meant that those methods LIED! We didn't change the database schema. We changed the attribute information on the class. That is wrong! It should be the other way around, where schema loading just calls the attributes API for you. And now it does! Yes, this means that there is nothing that happens in automatic schema loading that you couldn't manually do yourself. (There's still some funky cases where we hit the connection adapter that I need to handle, before we can turn off automatic schema detection entirely.) There were a few weird test failures caused by this that had to be fixed. The main source came from the fact that the attribute methods are now defined in terms of `attribute_names`, which has a clause like `return [] unless table_exists?`. I don't *think* this is an issue, since the only place this caused failures were in a fake adapter which didn't override `table_exists?`. Additionally, there were a few cases where tests were failing because a migration was run, but the model was not reloaded. I'm not sure why these started failing from this change, I might need to clear an additional cache in `reload_schema_from_cache`. Again, since this is not normal usage, and it's expected that `reset_column_information` will be called after the table is modified, I don't think it's a problem. Still, test failures that were unrelated to the change are worrying, and I need to dig into them further. Finally, I spent a lot of time debugging issues with the mutex used in `define_attribute_methods`. I think we can just remove that method entirely, and define the attribute methods *manually* in the call to `define_attribute`, which would simplify the code *tremendously*. Ok. now to make this damn thing public, and work on moving it up to Active Model.
-
- 31 1月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
Remaining are `limit`, `precision`, `scale`, and `type` (the symbol version). These will remain on the column, since they mirror the options to the `column` method in the schema definition DSL
-
- 13 1月, 2015 1 次提交
-
-
由 Ethan 提交于
-
- 10 1月, 2015 1 次提交
-
-
由 Carlos Antonio da Silva 提交于
Related to #10690.
-
- 06 1月, 2015 1 次提交
-
-
由 Sean Griffin 提交于
`initialize_internals_callback` will attempt to assign attributes from the current scope, which will fail if something defined the method and calls super (meaning it won't hit `method_missing`). Fixes #18339
-
- 04 1月, 2015 1 次提交
-
-
由 Rafael Mendonça França 提交于
-
- 30 12月, 2014 3 次提交
-
-
由 Sean Griffin 提交于
-
由 Sean Griffin 提交于
-
由 Sean Griffin 提交于
This API will require much less consuming code to change to accomodate the removal of automatic type casting from Arel. As long as the predicates are constructed using the `arel_table` off of an AR subclass, there will be no changes that need to happen.
-
- 27 12月, 2014 2 次提交
-
-
由 Sean Griffin 提交于
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
-
由 Sean Griffin 提交于
Construction of relations can be a hotspot, we don't want to create one of these in the constructor. This also allows us to do more expensive things in the predicate builder's constructor, since it's created once per AR::Base subclass
-
- 23 12月, 2014 1 次提交
-
-
由 Sean Griffin 提交于
If there is a method defined such as `find_and_do_stuff(id)`, which then gets called on an association, we will perform statement caching and the parent ID will not change on subsequent calls. Fixes #18117
-
- 04 12月, 2014 1 次提交
-
-
由 Yves Senn 提交于
This `# :nodoc:` had the effect of hiding every method that follows. This meant that the API page for `ActiveRecord::Core` only contained `configurations` and none of the following methods. Furthermore this `# :nodoc:` had no effect on `maintain_test_schema`. Those `mattr_accessor` inside the `included` block are not picked up by rdoc. /cc @zzak
-
- 30 11月, 2014 1 次提交
-
-
由 Sean Griffin 提交于
We never actually make use of it on the table, since we're constructing the select manager manually. It looks like if we ever actually were grabbing it from the table, we're grossly misusing it since it's meant to vary by AR class. Its existence on `Arel::Table` appears to be purely for convenience methods that are never used outside of tests. However, in production code it just complicates construction of the tables on the rails side, and the plan is to remove it from `Arel::Table` entirely. I'm not convinced it needs to live on `SelectManager`, etc either.
-
- 15 11月, 2014 1 次提交
-
-
由 Sean Griffin 提交于
We don't know which attributes will or won't be used, and we don't want to create massive bottlenecks at instantiation. Rather than doing *any* iteration over types and values, we can lazily instantiate the object. The lazy attribute hash should not fully implement hash, or subclass hash at any point in the future. It is not meant to be a replacement, but instead implement its own interface which happens to overlap.
-
- 01 11月, 2014 2 次提交
-
-
由 Sean Griffin 提交于
Sufficiently large integers cause `find` and `find_by` to raise `StatementInvalid` instead of `RecordNotFound` or just returning `nil`. Given that we can't cast to `nil` for `Integer` like we would with junk data for other types, we raise a `RangeError` instead, and rescue in places where it would be highly unexpected to get an exception from casting. Fixes #17380
-
由 Sean Griffin 提交于
It is internal use only. This is to avoid conflicting with users' method names. Fixes #17458
-
- 29 10月, 2014 1 次提交
-
-
由 Xavier Noria 提交于
The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
-
- 26 10月, 2014 1 次提交
-
-
由 Rafael Mendonça França 提交于
This will avoid naming clash with user defined methods
-
- 29 9月, 2014 2 次提交
-
-
由 Ben Woosley 提交于
Isolate access to @associations_cache and @aggregations cache to the 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.
-
由 Pete Higgins 提交于
Inspired by @tenderlove's work in c363fff2, this reduces the number of strings allocated when running callbacks for ActiveRecord instances. I measured that using this script: ``` require 'objspace' require 'active_record' require 'allocation_tracer' ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" ActiveRecord::Base.connection.instance_eval do create_table(:articles) { |t| t.string :name } end class Article < ActiveRecord::Base; end a = Article.create name: "foo" a = Article.find a.id N = 10 result = ObjectSpace::AllocationTracer.trace do N.times { Article.find a.id } end result.sort.each do |k,v| p k => v end puts "total: #{result.values.map(&:first).inject(:+)}" ``` When I run this against master and this branch I get this output: ``` pete@balloon:~/projects/rails/activerecord$ git checkout master M Gemfile Switched to branch 'master' pete@balloon:~/projects/rails/activerecord$ bundle exec ruby benchmark_allocation_with_callback_send.rb > allocations_before pete@balloon:~/projects/rails/activerecord$ git checkout remove-dynamic-send-on-built-in-callbacks M Gemfile Switched to branch 'remove-dynamic-send-on-built-in-callbacks' pete@balloon:~/projects/rails/activerecord$ bundle exec ruby benchmark_allocation_with_callback_send.rb > allocations_after pete@balloon:~/projects/rails/activerecord$ diff allocations_before allocations_after 39d38 < {["/home/pete/projects/rails/activesupport/lib/active_support/callbacks.rb", 81]=>[40, 0, 0, 0, 0, 0]} 42c41 < total: 630 --- > total: 590 ``` In addition to this, there are two micro-optimizations present: * Using `block.call if block` vs `yield if block_given?` when the block was being captured already. ``` pete@balloon:~/projects$ cat benchmark_block_call_vs_yield.rb require 'benchmark/ips' def block_capture_with_yield &block yield if block_given? end def block_capture_with_call &block block.call if block end def no_block_capture yield if block_given? end Benchmark.ips do |b| b.report("block_capture_with_yield") { block_capture_with_yield } b.report("block_capture_with_call") { block_capture_with_call } b.report("no_block_capture") { no_block_capture } end pete@balloon:~/projects$ ruby benchmark_block_call_vs_yield.rb Calculating ------------------------------------- block_capture_with_yield 124979 i/100ms block_capture_with_call 138340 i/100ms no_block_capture 136827 i/100ms ------------------------------------------------- block_capture_with_yield 5703108.9 (±2.4%) i/s - 28495212 in 4.999368s block_capture_with_call 6840730.5 (±3.6%) i/s - 34169980 in 5.002649s no_block_capture 5821141.4 (±2.8%) i/s - 29144151 in 5.010580s ``` * Defining and calling methods instead of using send. ``` pete@balloon:~/projects$ cat benchmark_method_call_vs_send.rb require 'benchmark/ips' class Foo def tacos nil end end my_foo = Foo.new Benchmark.ips do |b| b.report('send') { my_foo.send('tacos') } b.report('call') { my_foo.tacos } end pete@balloon:~/projects$ ruby benchmark_method_call_vs_send.rb Calculating ------------------------------------- send 97736 i/100ms call 151142 i/100ms ------------------------------------------------- send 2683730.3 (±2.8%) i/s - 13487568 in 5.029763s call 8005963.9 (±2.7%) i/s - 40052630 in 5.006604s ``` The result of this is making typical ActiveRecord operations slightly faster: https://gist.github.com/phiggins/e46e51dcc7edb45b5f98
-
- 22 9月, 2014 1 次提交
-
-
由 Ben Woosley 提交于
Simplify `find_by_statement_cache` interaction down to a class-level ivar with a single accessor `cached_find_by_statement`.
-