Commit Graph

6110 Commits

Author SHA1 Message Date
Akira Matsuda
8a4fdbbcd3 formats 2011-07-09 21:35:19 +09:00
Akira Matsuda
7f37ed0152 fix AR having() not to raise NoMethodError when the given argument does not respond to empty?
having raises NoMethodError: undefined method `empty?' when a Fixnum or Date/Time were passed via varargs
2011-07-09 21:35:09 +09:00
Jon Leighton
ca94acf0be Foo.joins(:bar).includes(:bar) should result in a single query with :bar as a join. Related: #1873. 2011-07-09 11:39:38 +01:00
Akira Matsuda
3cb67e442f find(:first) => first 2011-07-09 12:24:07 +02:00
Tomas D'Stefano
15f5c3bcbd Destroy association habtm record before destroying the record itself. Fixes issue #402. 2011-07-08 22:31:50 +01:00
Jon Leighton
6d2acc1195 Ensure that the foreign key gets set when doing record.create_association or record.create_association. Fixes #1960. 2011-07-08 21:03:40 +01:00
Santiago Pastorino
d7be017c7e Merge pull request #2002 from knapo/3-1-stable
Backport of #1997
2011-07-07 09:30:16 -07:00
knapo
7c051ab075 Make ActiveRecord::Batches#find_each to not return self.
This caused that `find_each` was producing extra db call taking all the records from db, and was less efficient than `ActiveRecord::Base#all`.
2011-07-07 18:13:29 +02:00
Dmitriy Kiriyenko
fd8dbfa776 Add require ActiveSupport delegation to ActiveRecord::Relation class. 2011-07-07 17:09:03 +02:00
Santiago Pastorino
ec27814883 Merge pull request #1990 from simonbaird/3-1-stable
rake db:test:purge creates mysql database with wrong charset & collation (3-1-stable)
2011-07-06 20:10:17 -07:00
Jon Leighton
fe2167f3f1 Don't construct association scope in initializer. This yields a big performance gain for cases where the association is never used to load the target, for example with preloading. Related: #1873. 2011-07-07 01:08:06 +01:00
Simon Baird
f44c3ea457 Fix charset/collate in mysql recreate_database
See new method mysql_creation_options. It is used by both
create_database and recreate_database so they are consistent.

(Manual cherry pick of 3ba3125b24)
2011-07-07 09:43:16 +10:00
Santiago Pastorino
3a92bc7906 Merge pull request #1789 from grantneufeld/schema_column_exists_options_hash_3_1
Fix default options argument on ActiveRecord::ConnectionAdaptors::Table#column_exists?
2011-07-06 12:00:35 -07:00
Santiago Pastorino
e7ac539c62 Merge pull request #1904 from oriolgual/1571_fix_for_3_1_stable
Fix #1571 for 3-1-stable
2011-07-06 11:57:36 -07:00
Oriol Gual
7c6a8406f4 Fix reverse order with new Arel Nodes (#1571) 2011-07-06 20:50:56 +02:00
Dieter Komendera
5a7c8e27eb Only call set_owner_attributes for has_one association if target exists. 2011-07-05 00:15:43 +01:00
Andrew White
cee27beb0c Use an instance variable to store the current masss assignment options
(cherry picked from commit 9f7442a3ab)
2011-07-04 06:49:15 +01:00
Vijay Dev
d764378489 Reversing the changes done in c278a2c while still resolving #1857.
The changes broke bulk migration tests and were fixed in 4d256bc6;
however that brought back the issue of #1857 and so this commit goes
back to the original scenario and just adds change_table to the list
of methods which are to be recorded in the CommandRecorder. The
method_missing now delegates all calls to the underlying connection as
before.
2011-07-03 17:28:03 +01:00
Aaron Patterson
896638238b a few minor performance improvements: fewer strings, fewer range objects, fewer method calls 2011-07-01 15:20:28 -07:00
Aaron Patterson
37eef89a2b calling super is super. if the other object is exactly equal, we can return early 2011-07-01 14:39:13 -07:00
Aaron Patterson
d5de496b87 remove unused codes 2011-07-01 14:39:10 -07:00
Aaron Patterson
2d459d25dc reduce calls to owners_by_key and to read_attribute, respond_to? etc 2011-07-01 09:56:00 -07:00
Jon Leighton
92c68dabd5 Add an extremely lulzy deprecation warning which tries to detect if AssociationReflection#build_association has been overridden, but ignores the block argument. 2011-06-30 23:39:43 +01:00
Jon Leighton
65813a6317 Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842. 2011-06-30 23:39:43 +01:00
Jon Leighton
da9c79b693 Remove AssociationReflection#create_association and AssociationReflection#create_association! - they are not called from anywhere. 2011-06-30 23:39:43 +01:00
Aaron Patterson
ef787cf3e3 match method signature of the superclass 2011-06-30 15:32:51 -07:00
Aaron Patterson
19f5576de3 call super rather than delegating to the other objects equal? method 2011-06-30 15:32:47 -07:00
Aaron Patterson
94d2b0b62a just alias eql? to == for frewer method calls 2011-06-30 15:32:42 -07:00
Aaron Patterson
83005cf501 only calculate method name once 2011-06-30 15:32:38 -07:00
Aaron Patterson
68b8710f8d cache the plural name on the reflection so we do not pay pluralize costs on joins 2011-06-30 15:32:34 -07:00
Santiago Pastorino
185ba01baf Bump up rack-cache and tzinfo 2011-06-30 10:09:52 -03:00
Jon Leighton
22bcb4e093 CommandRecorder should delegate in method_missing where possible. Fixes some tests in migration_test.rb under mysql. The problem was introduced in c278a2c5e1. 2011-06-30 00:48:03 +01:00
Jon Leighton
b09ef6d139 Define to_ary on ActiveRecord::Base to return nil. Improve performance of Array#flatten under 1.9, see comment for details. 2011-06-30 00:20:38 +01:00
Santiago Pastorino
4cee36044b Merge pull request #1885 from guilleiguaran/3-1-stable
Bump ARel to 2.1.3 (3-1-stable)
2011-06-28 14:59:10 -07:00
Guillermo Iguaran
4b12d7f369 Bump ARel to 2.1.3 2011-06-28 16:04:30 -05:00
Raimonds Simanovskis
cbf3e33176 Fix test_finding_with_cross_table_order_and_limit for Oracle
Use latest Arel syntax and pass each order by expression as separate argument to order method as otherwise invalid Oracle SQL is generated.
2011-06-28 13:49:35 -07:00
Ernie Miller
c26c273761 Support reversal of ARel orderings in reverse_sql_order 2011-06-28 13:12:58 -07:00
Vijay Dev
eb3e523434 record unsupported methods in CommandRecorder instead of letting the unsupported methods go through to the underlying db causing errors like duplicate columns to occur when rolling back migrations 2011-06-28 12:05:52 -07:00
Damien Mathieu
f170045c59 comparing different classes returns nil 2011-06-28 11:47:37 -07:00
Damien Mathieu
c5b43afd6c allow comparison on model objects - Closes #1858 2011-06-28 11:47:32 -07:00
Aaron Patterson
e0fae7265f remove useless assignment 2011-06-28 10:58:08 -07:00
Aaron Patterson
d8646163e5 lock_optimistically is typically true, so evaluate the common failure case first 2011-06-28 10:51:32 -07:00
Aaron Patterson
558b5bb490 reduce object allocation during AR instantiation 2011-06-28 10:22:47 -07:00
Aaron Patterson
196f92f366 remove the check for needs_type_condition? because ensure_proper_type will pick up the type column 2011-06-27 20:44:49 -07:00
Aaron Patterson
992b3b5e06 stop using && for the short circuit side effect 2011-06-27 18:16:16 -07:00
Aaron Patterson
5d954b4e38 let strings be converted to symbols inside the interpreter 2011-06-27 18:16:12 -07:00
Aaron Patterson
9fd0d91b26 avoice paying hash cost if there are no serialized attributes 2011-06-27 17:47:13 -07:00
Aaron Patterson
2fe088a53d cache column defaults for AR object instantiation 2011-06-27 17:47:09 -07:00
Aaron Patterson
b927f0a894 AR object instantiation is ~30% faster in the simple case 2011-06-27 16:15:44 -07:00
Aaron Patterson
0de56aac7f initialize instance variables 2011-06-27 14:47:32 -07:00