aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
* avoid Symbol#to_procVijay Dev2011-07-201-1/+1
|
* Explicitly require Active Support dependenciesNorman Clarke2011-07-191-0/+2
| | | | | | | | | | | | This fixes errors when using Active Record outside of Rails. In Rails, these files are required by other classes that are always loaded, so this error does not happen. Without core_ext/module/delegation, a NoMethodError is raised because `delegate` remains undefined. Without core_ext/class/attribute_acessors, an ArgumentError is raised because `delegate` does not receive a value for its :to option.
* ActiveRecord: Fix eager loading so that giving a blank order clause ↵Elliot Winkler2011-07-181-1/+1
| | | | generates valid SQL
* Merge pull request #195 from bigfix/active_model_include_serializationJosé Valim2011-07-182-81/+1
|\ | | | | ActiveModel support for the :include serialization option
| * ActiveModel support for the :include serialization optionJohn Firebaugh2011-07-172-81/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit moves support for the :include serialization option for serializing associated objects out of ActiveRecord in into ActiveModel. The following methods support the :include option: * serializable_hash * to_json * to_xml Instances must respond to methods named by the values of the :includes array (or keys of the :includes hash). If an association method returns an object that is_a?(Enumerable) (which AR has_many associations do), it is assumed to be a collection association, and its elements must respond to :serializable_hash. Otherwise it must respond to :serializable_hash itself. While here, fix #858, XmlSerializer should not singularize already singular association names.
| * We already have the record; no need to retrieve it againJohn Firebaugh2011-07-171-2/+2
| |
* | Refactor the code a bit to reduce the duplicationPrem Sichanugrist2011-07-171-17/+8
| |
* | Raise an ArgumentError if user passing less number of argument in the ↵Prem Sichanugrist2011-07-171-0/+10
|/ | | | | | | | | | | | | dynamic finder The previous behavior was unintentional, and some people was relying on it. Now the dynamic finder will always expecting the number of arguments to be equal or greater (so you can still pass the options to it.) So if you were doing this and expecting the second argument to be nil: User.find_by_username_and_group("sikachu") You'll now get `ArgumentError: wrong number of arguments (1 for 2).` You'll then have to do this: User.find_by_username_and_group("sikachu", nil)
* Merge pull request #2063 from elight/masterSantiago Pastorino2011-07-141-1/+2
|\ | | | | Patch for https://github.com/rails/rails/issues/2059
| * Fix and unit test for https://github.com/rails/rails/issues/2059Evan Light2011-07-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Cache key was incorrectly using timezone-dependent record#updated_at when it should be using a timezone-independent value to generate the cache key Minor refactoring to cache_key timezone test Closes #2059 Adds a test to validate the format of the cache_key for nil and present updated_at values Correctly handles updated_at == nil
* | Merge pull request #1807 from caius/find_in_batches_id_bugSantiago Pastorino2011-07-141-2/+5
|\ \ | |/ |/| Bugfix by stopping find_in_batches using the records after yielding.
| * Stop find_in_batches using the records after yielding.Caius Durling2011-06-211-2/+5
| | | | | | | | | | | | Currently if the code that calls .find_in_batches modifies the yielded array in place then .find_in_batches can enter an infinite loop searching with ruby object ids in the database instead of the primary key of records in the database. This happens because it naively assumes the yielded array hasn't been modified before calling #id on the last object in the array. And ruby (1.8 at least) alias' #id to #object_id so an integer is still returned no matter what the last object is. By moving finding the #id of the last object before yielding the array it means the calling code can do whatever it wants to the array in terms of modifying it in place, and .find_in_batches doesn't care.
* | Merge pull request #2042 from SAP-Oxygen/master-sqlbypass-patchSantiago Pastorino2011-07-121-7/+13
|\ \ | | | | | | Fix for SqlBypass session store (for master)
| * | Fix for SqlBypass session storeJoseph Wong2011-07-121-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two issues fixed: 1) connection_pool is not defined - needed by SessionStore#drop_table! and create_table! since c94651f 2) initialization of connection to the default of AR::Base.connection only occurred at the singleton level - the instance level method defined by cattr_accessor did not have this logic
* | | Fixed session ID fixation for ActiveRecord::SessionStoreJoseph Wong2011-07-121-2/+6
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I have found that Rails will take an invalid session ID specified by the client and materialize a session based on that session ID. This means that it is possible, among other things, for a client to use an arbitrarily weak session ID or for a client to resurrect a previous used session ID. In other words, we cannot guarantee that all session IDs are generated by the server and that they are (statistically) unique through time. The fix is to always generate a new session ID in #get_session if an existing session cannot be found under the incoming session ID. Also added new tests that make sure that an invalid session ID is never materialized into a new session, regardless of whether it comes in via a cookie or a URL parameter (when :cookie_only => false).
* | Fix exception if old and new targets are both nil. Fixes #1471.Jon Leighton2011-07-121-1/+1
| |
* | Merge pull request #1823 from gnarg/masterSantiago Pastorino2011-07-101-2/+2
|\ \ | | | | | | Log instrumentation name for exists? queries
| * | Log instrumentation name for exists? queriesJon Guymon2011-06-221-2/+2
| | |
* | | to_key on a destroyed model should return nilSantiago Pastorino2011-07-091-1/+1
| | |
* | | fix AR having() not to raise NoMethodError when the given argument does not ↵Akira Matsuda2011-07-091-3/+3
| | | | | | | | | | | | | | | | | | respond to empty? having raises NoMethodError: undefined method `empty?' when a Fixnum or Date/Time were passed via varargs
* | | Foo.joins(:bar).includes(:bar) should result in a single query with :bar as ↵Jon Leighton2011-07-091-1/+11
| | | | | | | | | | | | a join. Related: #1873.
* | | Merge branch 'master' of git://github.com/lifo/docrailsXavier Noria2011-07-094-30/+30
|\ \ \
| * | | :conditions => whereAkira Matsuda2011-07-081-1/+1
| | | |
| * | | :joins => joinsAkira Matsuda2011-07-081-12/+12
| | | |
| * | | :include => includesAkira Matsuda2011-07-081-7/+7
| | | |
| * | | find(:first) => firstAkira Matsuda2011-07-082-6/+6
| | | |
| * | | find(:all) => allAkira Matsuda2011-07-083-22/+22
| | | |
* | | | Destroy association habtm record before destroying the record itself. Fixes ↵Tomas D'Stefano2011-07-082-12/+17
| | | | | | | | | | | | | | | | issue #402.
* | | | Ensure that the foreign key gets set when doing record.create_association or ↵Jon Leighton2011-07-081-2/+11
| | | | | | | | | | | | | | | | record.create_association. Fixes #1960.
* | | | Refactor PostgreSQLAdapter a bitDaniel Schierbeck2011-07-081-16/+18
| | | | | | | | | | | | | | | | | | | | Move the private method #extract_schema_and_table into a separate Utils module so that it can be tested without resorting to #send.
* | | | Use Enumerable#with_index. We're on Ruby > 1.8.7Akira Matsuda2011-07-081-2/+1
| | | |
* | | | Merge pull request #1997 from knapo/masterSantiago Pastorino2011-07-071-2/+0
|\ \ \ \ | | | | | | | | | | Make `ActiveRecord::Batches#find_each` to not return `self`.
| * | | | Make `ActiveRecord::Batches#find_each` to not return `self`.knapo2011-07-071-2/+0
| | | | | | | | | | | | | | | | | | | | This caused that `find_each` was producing extra db call taking all the records from db, and was less efficient than `ActiveRecord::Base#all`.
* | | | | Add require ActiveSupport delegation to ActiveRecord::Relation class.Dmitriy Kiriyenko2011-07-071-0/+1
|/ / / /
* | | | Merge pull request #1120 from lysenko/collection_singular_idsSantiago Pastorino2011-07-061-1/+1
|\ \ \ \ | | | | | | | | | | collection_singular_ids ignores association :include option
| * | | | Fix bug in collection_singular_ids on has many through association with ↵Anatoliy Lysenko2011-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | conditions and includes, when condtions references tables from includes. Test fail because of invalid sql: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: comments.id: SELECT "posts".id FROM "posts" INNER JOIN "readers" ON "posts"."id" = "readers"."post_id" WHERE "readers"."person_id" = 1 AND (comments.id is null) Bug described in github#925 This commit will revert fix from https://github.com/rails/rails/commit/3436fdfc12d58925e3d981e0afa61084ea34736c , but tests is ok. Bug described in #6569 ticket.
* | | | | Merge pull request #1989 from simonbaird/masterSantiago Pastorino2011-07-061-5/+8
|\ \ \ \ \ | | | | | | | | | | | | rake db:test:purge creates mysql database with wrong charset & collation (master branch)
| * | | | | Fix charset/collate in mysql recreate_databaseSimon Baird2011-07-071-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See new method mysql_creation_options. It is used by both create_database and recreate_database so they are consistent. (Cherry pick of 3ba3125b24b532876c95c8d9d00c9b69faab5a60)
* | | | | | Don't construct association scope in initializer. This yields a big ↵Jon Leighton2011-07-072-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | performance gain for cases where the association is never used to load the target, for example with preloading. Related: #1873.
* | | | | | Remove case statement changes from 2e0840d and 56ac32a. Inheritance FTW.Ernie Miller2011-07-061-1/+1
| |/ / / / |/| | | |
* | | | | Merge pull request #1273 from jeremyf/feature-association-proxy-sendSantiago Pastorino2011-07-062-1/+2
|\ \ \ \ \ | | | | | | | | | | | | Addresses an inconsistency in the ActiveRecord::Base.method_missing handl
| * | | | | Addresses an inconsistency in the ActiveRecord::Base.method_missing handling ↵Jeremy Friesen2011-05-242-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | of dynamic finder methods and the passing of the &block parameter for :find_by_attributes.
* | | | | | Merge pull request #1979 from bogdan/association_sum_array_compatibilityJon Leighton2011-07-061-2/+6
|\ \ \ \ \ \ | | | | | | | | | | | | | | Fixed AR::Relation#sum compatibility with Array#sum
| * | | | | | Fixed AR::Relation#sum compatibility with Array#sumBogdan Gusiev2011-07-051-2/+6
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | In order make Relation behavior closer to Array Made Relation#sum to accept block and delegate it to Array#sum
* | | | | | Merge pull request #1968 from bogdan/associations_find_array_compatibility2Santiago Pastorino2011-07-051-3/+7
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Fixed CollectionAssociation#find to be compatible with Array#find
| * | | | | Fixed CollectionAssociation#find to be compatible with Array#findBogdan Gusiev2011-07-051-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make CollectionAssociation behave closer to Array Add the ability to pass block to #find method just like Array#find does.
* | | | | | Merge branch 'master' of git://github.com/lifo/docrailsXavier Noria2011-07-052-6/+6
|\ \ \ \ \ \
| * | | | | | minor changesVijay Dev2011-06-271-2/+2
| | | | | | |
| * | | | | | replace find(all) with allVijay Dev2011-06-261-3/+3
| | | | | | |
| * | | | | | fix typo in method nameVijay Dev2011-06-251-1/+1
| | | | | | |