aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
* ActiveRecord: sum expression returns string '0' for no records, fixedTim Macfarlane2012-10-153-1/+10
|
* use `setup` for setting up the testAaron Patterson2012-10-151-5/+1
|
* buckets hash isn't public, so use symbol keys to avoid stringAaron Patterson2012-10-151-8/+8
| | | | allocations
* Move two hotspots to use Hash[] rather than Hash#dupAaron Patterson2012-10-151-3/+5
| | | | https://bugs.ruby-lang.org/issues/7166
* refactoring of uniqueness validate_eachAngelo Capilleri2012-10-141-1/+2
| | | | get scope_value only one time dependig on reflection
* Fix typo in inet and cidr savingMiguel Herranz2012-10-142-1/+14
|
* #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 Add change of previous commit to CHANGELOG.mdArturo Pie2012-10-131-0/+4
|
* #7914 get default value when type uses schema nameArturo Pie2012-10-134-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-123-4/+73
|
* 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-124-14/+10
| | | | | | | | | | | | 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.
* Cleanup trailing whitespacesdfens2012-10-125-5/+5
|
* 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 pull request #7887 from senny/remove_unused_requires_in_ar_testsVijay Dev2012-10-104-4/+0
|\ | | | | remove duplicated require statements in AR test cases
| * remove duplicated require statements in AR test casesYves Senn2012-10-094-4/+0
| |
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-10-117-24/+39
|\ \ | | | | | | | | | | | | | | | 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
| | |
| * | gradually moving documentation to new hash syntaxAvnerCohen2012-10-102-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-092-1/+9
|\ \ \ | |_|/ |/| | Fix has_many assocation w/select load after create
| * | Fix has_many assocation w/select load after createErnie Miller2012-10-052-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-059-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-059-13/+13
| | |
* | | 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
| | |
* | | Add CHANGELOG entry for "Fixtures" -> "FixtureSet"Alexey Muranov2012-10-071-1/+13
| | |
* | | Move/rename files to follow naming conventionsAlexey Muranov2012-10-073-1/+1
| | |
* | | Deprecate "Fixtures" constantAlexey Muranov2012-10-071-0/+8
| | |
* | | Rename "Fixtures" class to "FixtureSet"Alexey Muranov2012-10-0711-58/+58
| | | | | | | | | | | | 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.
* | | Remove unneeded requireRafael Mendonça França2012-10-061-1/+0
| | |
* | | Move multiparameter attributes related tests to its own fileRafael Mendonça França2012-10-062-337/+351
| | |
* | | PostgreSQL, quote table names when fetching the primary key. Closes #5920Yves Senn2012-10-053-1/+10
|/ /
* | 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
* | Fix CHANGELOG entry [ci skip]Rafael Mendonça França2012-10-041-4/+4
| |
* | Count returns 0 without querying if parent is not savedFrancesco Rodriguez2012-10-035-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| |
* | fix warning: method redefinedkennyj2012-10-022-2/+2
| |
* | Merge pull request #7822 from lulalala/reset-counter-cache-for-has-many-throughRafael Mendonça França2012-10-025-4/+28
|\ \ | | | | | | Fix reset_counters crashing on has_many :through associations.