Commit Graph

9608 Commits

Author SHA1 Message Date
aditya-kapoor
90e60aa469 Added some more documentation for define_readers and define_writer of the Association and its inherited classes 2013-05-15 15:31:53 +05:30
aditya-kapoor
da8fff528d Added some more documentation for ActiveRecord::Associations::Builder::Association class 2013-05-15 15:07:55 +05:30
aditya-kapoor
0fbf31b200 Added documentation for ActiveRecord::Associations::Builder::Association class 2013-05-15 12:28:08 +05:30
Anton Kalyaev
ddf07d2183 improved doc for ActiveRecord#find_by_sql method (Refs #10599) [ci skip] 2013-05-14 10:16:56 +04:00
aditya-kapoor
87d71b02b8 Added documentation for model migration generation 2013-05-14 00:27:52 +05:30
Neeraj Singh
7b24cf0391 emphasize that callbacks are called in destroy_all
Cleaned up rdoc a bit emphasizing that callbacks are called. Also
removed the stress on the fact that records are always removed.

If callbacks return false then records will not be deleted.
2013-05-13 11:39:09 -04:00
Vijay Dev
d8b8c0ef87 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activesupport/lib/active_support/callbacks.rb
2013-05-12 15:57:14 +05:30
Vijay Dev
1a9766f128 copy edits [ci skip] 2013-05-12 15:52:09 +05:30
wangjohn
346cda4f34 Adding documentation to the automatic inverse_of finder. 2013-05-11 23:05:36 -04:00
Rafael Mendonça França
d9e8ec61a4 Improve CHANGELOG entry [ci kip] 2013-05-11 23:51:27 -03:00
Kyle Stevens
443f8dd5cd Call assume_migrated_upto_version on connection
Call assume_migrated_upto_version on connection to prevent it from first
being picked up in method_missing. In the base class, Migration,
method_missing expects the argument to be a table name, and calls
proper_table_name on the arguments before sending to connection. If
table_name_prefix or table_name_suffix is used, the schema version changes
to prefix_version_suffix, breaking `rake test:prepare`.

Fixes #10411.
2013-05-11 22:39:39 -04:00
Rafael Mendonça França
51157c9b46 Merge pull request #10567 from neerajdotname/read_attribute_before_type_cast_should_accept_symbol
read_attribute_before_type_cast should accept symbol
2013-05-11 14:36:06 -07:00
Rafael Mendonça França
0215faf472 Merge pull request #10572 from nertzy/dont-modify-options-hash-in-primary-key
Don't modify args in TableDefinition#primary_key
2013-05-11 16:52:33 -03:00
Neeraj Singh
3e0c06d8ab read_attribute_before_type_cast should accept symbol 2013-05-11 03:12:38 -04:00
Ben Woosley
fba18f1994 Extract JoinDependency#join_relation to DRY the repeated application of the #join_associations. 2013-05-10 17:46:04 +02:00
Ben Woosley
35c198ca9b In #apply_join_dependency, we can apply the #where in-place because relation is always a new object.
Thanks to the #except we call at the top of the method.
2013-05-10 17:46:04 +02:00
Ben Woosley
75fe7434a8 DRY-up join dependency creation by extracting construct_join_depdency 2013-05-10 17:46:04 +02:00
Ben Woosley
88219cc88a Pull the excepts into apply_join_dependency, for the sake of DRY. 2013-05-10 17:46:04 +02:00
Ben Woosley
1dcb1ccc9d Simplify conditions within apply_join_dependency 2013-05-10 17:46:04 +02:00
Ben Woosley
cd04a99ba4 Move the except(:select) inside the construct_limited_ids_condition method to pair it closely with its motivation. 2013-05-10 17:46:04 +02:00
Ben Woosley
ec75ff3451 Reject blank order_values within #columns_for_distinct, as the orders aren't used at all on non-postgres adapters. 2013-05-10 17:45:38 +02:00
Jon Leighton
32a5cad1e4 Move #proxy_association method to AssociationRelation 2013-05-10 16:39:27 +02:00
Jon Leighton
1b022990c7 Merge pull request #6792 from Empact/postgres-distinct
Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"
2013-05-10 07:36:11 -07:00
Daniel Schierbeck
1cc63e94db Don't try to EXPLAIN select_db calls 2013-05-10 16:21:59 +02:00
Ben Woosley
15d6e4dce7 Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"
The combination of a :uniq => true association and the #distinct call
in #construct_limited_ids_condition combine to create invalid SQL, because
we're explicitly selecting DISTINCT, and also sending #distinct on to AREL,
via the relation#distinct_value.

Rather than build a select distinct clause in #construct_limited_ids_condition,
I set #distinct! and pass just the columns into the select statement.
This requires introducing a #columns_for_distinct method to return the
select columns but not the statement itself.
2013-05-10 16:13:46 +02:00
Jon Leighton
d7abe91cc7 Set the inverse when association queries are refined
Suppose Man has_many interests, and inverse_of is used.

Man.first.interests.first.man will correctly execute two queries,
avoiding the need for a third query when Interest#man is called. This is
because CollectionAssociation#first calls set_inverse_instance.

However Man.first.interests.where("1=1").first.man will execute three
queries, even though this is obviously a subset of the records in the
association.

This is because calling where("1=1") spawns a new Relation object from
the CollectionProxy object, and the Relation has no knowledge of the
association, so it cannot set the inverse instance.

This commit solves the problem by making relations spawned from
CollectionProxies return a new Relation subclass called
AssociationRelation, which does know about associations. Records loaded
from this class will get the inverse instance set properly.

Fixes #5717.

Live commit from La Conf! 
2013-05-10 10:36:26 +02:00
aditya-kapoor
ff34afc202 Added documentation for ActiveRecord::Generators::MigrationGenerator.next_migration_number 2013-05-10 00:03:29 +05:30
aditya-kapoor
fe7cf89193 Added documentation for ActiveRecord::Base#next_migration_number 2013-05-09 23:50:05 +05:30
Neeraj Singh
d9490631d2 minor rdoc cleanup for reflection methods 2013-05-09 02:06:03 -04:00
Neeraj Singh
fdba949b47 extracted piece of code into a method
In order to fix #10421 I need to enable merge to take an option
so that relations could be merged without making the last where
condition to win.

That fix would forever reside in 4-0-stable branch and would not be
merged to master since using scope without lambda has been deprecated.

In this commit I have extracted code into a method and I think it
makes code look better. Hence the request to merge it in both
master and 4-0-stable.

If there is any concern then this code can be merged only in
4-0-stable and that would be fine too.
2013-05-08 15:21:52 -04:00
Rafael Mendonça França
d4de2c34c5 Merge pull request #10521 from yahonda/sanitize_oracle
Remove current_adapter? from test_sanitize_sql_hash_handles_associations
2013-05-08 10:44:16 -07:00
Prathamesh Sonpatki
b5429eec60 Fix Typo existant -> existent [ci skip] 2013-05-08 09:50:46 +05:30
wangjohn
26d19b4661 Created a method to automatically find inverse associations and cache
the results. Added tests to check to make sure that inverse associations are
automatically found when has_many, has_one, or belongs_to associations
are defined.
2013-05-07 23:24:43 -04:00
Yasuo Honda
798cf2b9ef Remove current_adapter? from test_sanitize_sql_hash_handles_associations
Because of each adapter implementation differences,
`expected_value` string needed to be handled by each adapter.
This commit removes current_adapter
by using ActiveRecord::ConnectionAdapters::Quoting methods.
2013-05-08 06:40:15 +09:00
Aaron Patterson
2b5e4f7f98 Revert "Merge pull request #10455 from patricksrobertson/bigserial_id_not_identifying_pk"
This reverts commit 3043d45eefc3776d5f3a9e7d212a01f99d869ef8, reversing
changes made to ca0275d36b395631725c4583db5a45c06443fdb9.
2013-05-07 10:39:41 -07:00
Patrick Robertson
0e00c6b296 Handle other pk types in PostgreSQL gracefully.
In #10410 it was noted that you can no longer create PK's with the
type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly
because the newer adapter is checking for column type with the
id column instead of just letting it pass through like it did
before.

Side effects:
You may just create a PK column of a type that you really don't
want to be your PK. As far as I can tell this was allowed in 3.2.X
and perhaps an exception should be raised if you try and do
something extremely dumb.
2013-05-07 08:21:41 -04:00
Rafael Mendonça França
17c1143af9 Improve CHANGELOG entry [ci skip] 2013-05-06 22:22:43 -03:00
Rafael Mendonça França
19d32e89af Merge pull request #10489 from greenriver/ar_counter_cache_multiple_destroy
Confirm a record has not already been destroyed before decrementing counter cache

Conflicts:
	activerecord/CHANGELOG.md
2013-05-06 22:22:07 -03:00
Ben Tucker
228720ef19 Confirm a record has not already been destroyed before decrementing
counter cache

At present, calling destroy multiple times on the same record results
in the belongs_to counter cache being decremented multiple times. With
this change the record is checked for whether it is already destroyed
prior to decrementing the counter cache.
2013-05-06 21:09:14 -04:00
Rafael Mendonça França
0f97ac6647 Fix test asserting the sanitized SQL hash differently to some adapters 2013-05-06 22:02:34 -03:00
Waynn Lue
54644f2e78 XML-files isn't a word 2013-05-06 17:22:18 -07:00
Rafael Mendonça França
9073400253 Merge pull request #10352 from zohlgren/fix_activerecord_sanitization_sanitize_sql_hash
Fix bug in ActiveRecord::Sanitization#sanitize_sql_hash_for_conditions
2013-05-06 17:05:20 -07:00
Zach Ohlgren
a6bc35c82c Fix bug in ActiveRecord::Sanitization#sanitize_sql_hash_for_conditions
Fixing CHANGLOG description

Remove extra line.

Remove blank lines.
2013-05-06 17:03:18 -07:00
Neeraj Singh
86ac1d9bb2 fix failing test caused by 3771e4d511 2013-05-06 16:49:06 -04:00
Neeraj Singh
3771e4d511 raise IrreversibleMigration if no column given
fixes #10419

Following code should raise  IrreversibleMigration. But the code was
failing since options is an array and not a hash.

def change
  change_table :users do |t|
    t.remove_index [:name, :email]
  end
end

Fix was to check if the options is a Hash before operating on it.
2013-05-06 15:16:42 -04:00
Akshay Khole
b79c1314a9 fix to remove warning on postgres adapter test.
Warning was: "/vagrant/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:63:
warning: ambiguous first argument; put parentheses or even spaces"
2013-05-05 00:54:45 +05:30
Akshay Khole
20549051f8 Changing method call according to coding conventions 2013-05-05 00:25:22 +05:30
Rafael Mendonça França
903a2c2d33 Merge pull request #10458 from bwbuchanan/issue-10451
Make SchemaDumper emit "id: :uuid" when using UUID primary keys
2013-05-04 05:49:59 -07:00
Brian Buchanan
fa87e3166f Make SchemaDumper emit "id: :uuid" when appropriate. Fixes #10451. 2013-05-03 16:05:55 -07:00
Aaron Patterson
4c242e6d33 Squashed commit of the following:
commit 2683de5da85135e8d9fe48593ff6167db9d64b18
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri May 3 11:29:20 2013 -0700

    cannot support infinite ranges right now

commit cebb6acef2c3957f975f6db4afd849e535126253
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri May 3 11:26:12 2013 -0700

    reverting infinity comparison

commit 385f7e6b4efd1bf9b89e8d607fcb13e5b03737ea
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri May 3 11:23:28 2013 -0700

    Revert "Added ability to compare date/time with infinity"

    This reverts commit 38f28dca3aa16efd6cc3af6453f2e6b9e9655ec1.

    Conflicts:
    	activesupport/CHANGELOG.md
    	activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb
    	activesupport/test/core_ext/date_ext_test.rb
    	activesupport/test/core_ext/date_time_ext_test.rb
    	activesupport/test/core_ext/numeric_ext_test.rb
    	activesupport/test/core_ext/time_ext_test.rb
    	activesupport/test/core_ext/time_with_zone_test.rb

commit 0d799a188dc12b18267fc8421675729917610047
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri May 3 11:18:53 2013 -0700

    Revert "Refactor infinite comparable definition a bit"

    This reverts commit dd3360e05e4909f2f0c74a624cccc2def688f828.

commit 42dec90e49745bbfae546f0560b8783f6b48b074
Author: Aaron Patterson <aaron.patterson@gmail.com>
Date:   Fri May 3 11:18:47 2013 -0700

    Revert "Require 'active_support/core_ext/module/aliasing' in the infinite_comparable module"

    This reverts commit 7003e71c13c53ec3d34250560fbf80b8381df693.
2013-05-03 11:29:35 -07:00