aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
Commit message (Collapse)AuthorAgeFilesLines
* Fix typo in inet and cidr savingMiguel Herranz2012-10-141-1/+1
|
* #7914 Remove code for unsupported postgreSQL version.Arturo Pie2012-10-132-6/+0
| | | | | | | Remove parsing of character type default values for 8.1 formatting since Rails doesn't support postgreSQL 8.1 anymore. Remove misleading comment unrelated to code.
* #7914 Using a better way to get the defaults from db.Arturo Pie2012-10-132-6/+7
| | | | | | | | | According to postgreSQL documentation: (http://www.postgresql.org/docs/8.2/static/catalog-pg-attrdef.html) we should not be using 'adsrc' field because this field is unaware of outside changes that could affect the way that default values are represented. Thus, I changed the queries to use "pg_get_expr(adbin, adrelid)" instead of the historical "adsrc" field.
* #7914 get default value when type uses schema nameArturo Pie2012-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL adapter properly parses default values when using multiple schemas and domains. When using domains across schemas, PostgresSQL prefixes the type of the default value with the name of the schema where that type (or domain) is. For example, this query: ``` SELECT a.attname, d.adsrc FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = "defaults"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum; ``` could return something like "'<default_value>'::pg_catalog.text" or "(''<default_value>'::pg_catalog.text)::text" for the text columns with defaults. I modified the regexp used to parse this value so that it ignores anything between ':: and \b(?:character varying|bpchar|text), and it allows to have optional parens like in the above second example.
* performance improvements to joins!Aaron Patterson2012-10-122-5/+13
| | | | | | | | | | | | | | | | | | Before: Calculating ------------------------------------- ar 87 i/100ms ------------------------------------------------- ar 823.4 (±11.8%) i/s - 4089 in 5.070234s After: Calculating ------------------------------------- ar 88 i/100ms ------------------------------------------------- ar 894.1 (±3.9%) i/s - 4488 in 5.028161s Same test as 3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5
* Speed up relation merging by reducing calls to Array#-Aaron Patterson2012-10-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before: Calculating ------------------------------------- ar 83 i/100ms ------------------------------------------------- ar 832.1 (±4.0%) i/s - 4233 in 5.096611s after: Calculating ------------------------------------- ar 87 i/100ms ------------------------------------------------- ar 839.0 (±9.3%) i/s - 4176 in 5.032782s Benchmark: require 'config/environment' require 'benchmark/ips' GC.disable unless User.find_by_login('tater') u = User.new u.login = 'tater' u.save! end def active_record user = User.find_by_login('tater') starred = user.starred_items.count end active_record Benchmark.ips do |x| x.report("ar") { active_record } end
* trailling whitespace cleanup in query_methods.rbYves Senn2012-10-121-12/+12
|
* learn ActiveRecord::QueryMethods#order work with hash argumentsTima Maslyuchenko2012-10-121-4/+47
|
* Don't allocate new strings in compiled attribute methodsJon Leighton2012-10-122-20/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves memory and performance without having to use symbols which present DoS problems. Thanks @headius and @tenderlove for the suggestion. Benchmark --------- require 'active_record' require 'benchmark/ips' ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') class Post < ActiveRecord::Base connection.create_table :posts, force: true do |t| t.string :name end end post = Post.create name: 'omg' Benchmark.ips do |r| r.report('Post.new') { Post.new name: 'omg' } r.report('post.name') { post.name } r.report('post.name=') { post.name = 'omg' } r.report('Post.find(1).name') { Post.find(1).name } end Before ------ Calculating ------------------------------------- Post.new 1419 i/100ms post.name 7538 i/100ms post.name= 3024 i/100ms Post.find(1).name 243 i/100ms ------------------------------------------------- Post.new 20637.6 (±12.7%) i/s - 102168 in 5.039578s post.name 1167897.7 (±18.2%) i/s - 5186144 in 4.983077s post.name= 64305.6 (±9.6%) i/s - 317520 in 4.998720s Post.find(1).name 2678.8 (±10.8%) i/s - 13365 in 5.051265s After ----- Calculating ------------------------------------- Post.new 1431 i/100ms post.name 7790 i/100ms post.name= 3181 i/100ms Post.find(1).name 245 i/100ms ------------------------------------------------- Post.new 21308.8 (±12.2%) i/s - 105894 in 5.053879s post.name 1534103.8 (±2.1%) i/s - 7634200 in 4.979405s post.name= 67441.0 (±7.5%) i/s - 337186 in 5.037871s Post.find(1).name 2681.9 (±10.6%) i/s - 13475 in 5.084511s
* Revert "Key the attributes hash with symbols"Jon Leighton2012-10-123-12/+8
| | | | | | | | | | | | This reverts commit 86c3dfbd47cb96af02daaa655963292b1a1b110e. Conflicts: activerecord/lib/active_record/attribute_methods/read.rb Reason: whilst this increased performance, it also presents a DoS risk via memory exhaustion if users were allowing user input to dictate the arguments of read/write_attribute. I will investigate alternative ways to cut down on string allocations here.
* Eager autoload Preloader classesJohn Firebaugh2012-10-101-10/+14
| | | | | Without eager autoloading, these would be autoloaded only when #preloader_for is called, which is too late in threaded applications.
* Remove the leading :: constant qualifier in the ActiveRecord::Fixtures ↵Jeremy Kemper2012-10-101-1/+1
| | | | deprecation message
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-10-115-22/+37
|\ | | | | | | | | | | Conflicts: activerecord/lib/active_record/persistence.rb railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
| * copy edits [ci skip]Vijay Dev2012-10-111-2/+2
| |
| * Added clarity to update_column(s)Adam Haymond2012-10-101-2/+2
| |
| * Fixed unclosing tagAvnerCohen2012-10-091-1/+1
| |
| * Fix typo: 'this also mean' -> 'this also means'Jeffrey Hardy2012-10-081-1/+1
| |
| * Fix missing typewriter tagLincoln Lee2012-10-081-1/+1
| |
| * Add CollectionAssociation#destroy to ActiveRecord::Association::ClassMethods ↵Samuel Cochran2012-10-051-3/+15
| | | | | | | | code docs
| * fix example in Migration docs [ci skip]Francesco Rodriguez2012-09-301-1/+1
| |
| * add change_table transformation to Migration docs [ci skip]Francesco Rodriguez2012-09-301-16/+19
| |
* | Merge pull request #7859 from ernie/fix-collection-associations-with-selectAaron Patterson2012-10-091-1/+1
|\ \ | | | | | | Fix has_many assocation w/select load after create
| * | Fix has_many assocation w/select load after createErnie Miller2012-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you create a new record via a collection association proxy that has not loaded its target, and which selects additional attributes through the association, then when the proxy loads its target, it will inadvertently trigger an ActiveModel::MissingAttributeError during attribute writing when CollectionAssociation#merge_target_lists attempts to do its thing, since the newly loaded records will possess attributes the created record does not. This error also raises a bogus/confusing deprecation warning when accessing the association in Rails 3.2.x, so cherry-pick would be appreciated!
| * | Revert "Use flat_map { } instead of map {}.flatten"Santiago Pastorino2012-10-056-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit abf8de85519141496a6773310964ec03f6106f3f. We should take a deeper look to those cases flat_map doesn't do deep flattening. irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten => [1, 3, 1, 2] irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i} => [[1, 3], [1, 2]]
| * | Use flat_map { } instead of map {}.flattenSantiago Pastorino2012-10-056-9/+9
| | |
* | | remove unused `expand_range_bind_variables` methodYves Senn2012-10-081-17/+0
| | | | | | | | | | | | this method was not used, not documented and not tested.
* | | Should use app.paths instead of specific path.kennyj2012-10-081-1/+2
| | |
* | | Move/rename files to follow naming conventionsAlexey Muranov2012-10-072-1/+1
| | |
* | | Deprecate "Fixtures" constantAlexey Muranov2012-10-071-0/+8
| | |
* | | Rename "Fixtures" class to "FixtureSet"Alexey Muranov2012-10-073-21/+21
| | | | | | | | | | | | Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`. Instances of this class normally hold a collection of fixtures (records) loaded either from a single YAML file, or from a file and a folder with the same name. This change make the class name singular and makes the class easier to distinguish from the modules like `ActiveRecord::TestFixtures`, which operates on multiple fixture sets, or `DelegatingFixtures`, `::Fixtures`, etc., and from the class `ActiveRecord::Fixture`, which corresponds to a single fixture.
* | | PostgreSQL, quote table names when fetching the primary key. Closes #5920Yves Senn2012-10-051-1/+1
|/ /
* | Update activerecord/lib/active_record/persistence.rbAdam Haymond2012-10-041-2/+2
| | | | | | - Changed the comments documentation for the update_column(s) methods to add a little bit of clarity
* | Count returns 0 without querying if parent is not savedFrancesco Rodriguez2012-10-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patches `CollectionAssociation#count` to return 0 without querying if the parent record is new. Consider the following code: class Account has_many :dossiers end class Dossier belongs_to :account end a = Account.new a.dossiers.build # before patch a.dossiers.count # SELECT COUNT(*) FROM "dossiers" WHERE "dossiers"."account_id" IS NULL # => 0 # after a.dosiers.count # fires without sql query # => 0 Fixes #1856.
* | RefactorSantiago Pastorino2012-10-031-5/+4
| |
* | Merge pull request #7822 from lulalala/reset-counter-cache-for-has-many-throughRafael Mendonça França2012-10-021-2/+7
|\ \ | | | | | | Fix reset_counters crashing on has_many :through associations.
| * | Fix reset_counters() crashing on has_many :through associations.lulalala2012-10-021-2/+7
| | | | | | | | | | | | | | | The counter column name in the intermediate model need to be access via the through reflection.
* | | Merge pull request #7708 from bdurand/optimize_log_subscribersRafael Mendonça França2012-10-011-4/+6
|\ \ \ | |/ / |/| | Optimize log subscribers to check if the log level is sufficient
| * | Optimize log subscribers to check if the log level is sufficient before ↵Brian Durand2012-09-301-4/+6
| | | | | | | | | | | | performing an operations.
* | | small refactoring of build_relation in uniquenessAngelo Capilleri2012-09-291-5/+3
| | | | | | | | | | | | | | | reflection init as 'if' stantment. column is always the same expression and depends from the changing of attributes
* | | Fix syntax error with no US-ASCII charRafael Mendonça França2012-09-281-1/+1
| |/ |/|
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-2817-186/+161
|\ \ | | | | | | | | | | | | Conflicts: actionpack/lib/action_view/helpers/asset_tag_helper.rb
| * | remove added indentation from the last commit [ci skip]Francesco Rodriguez2012-09-221-1/+1
| | |
| * | update AR::Validations documentation [ci skip]Francesco Rodriguez2012-09-225-28/+28
| | |
| * | nodoc AR::Railtie [ci skip]Francesco Rodriguez2012-09-212-4/+4
| | |
| * | update AR::Scoping documentation [ci skip]Francesco Rodriguez2012-09-212-91/+77
| | |
| * | add :nodoc: directive to AR::Fixtures::File [ci skip]Francesco Rodriguez2012-09-211-1/+1
| | |
| * | fix AR::Coders::YAMLColumn nodoc [ci skip]Francesco Rodriguez2012-09-211-4/+2
| | |
| * | update AR/attribute_methods documentation [ci skip]Francesco Rodriguez2012-09-214-26/+36
| | |
| * | Better docs for overriding inheretance columnSteve Klabnik2012-09-221-5/+2
| | |
| * | fix AR::AttributeMethods::Dirty :nodoc: [ci skip]Francesco Rodriguez2012-09-211-4/+4
| | |