Commit Graph

9623 Commits

Author SHA1 Message Date
Aaron Patterson
28574961fb test refactor 2013-05-16 13:33:35 -07:00
Bogdan Gusiev
711097e6a5 Add more data to AR::UnknownAttributeError
begin
  Topic.new("hello" => "world")
rescue ActiveRecord::UnknownAttributeError => e
  e.record # => #<Topic ... >
  e.attribute # => "hello"
end
2013-05-16 13:31:35 -07:00
Aaron Patterson
7816b9852b Merge pull request #10619 from alno/top_level_array_in_postgres_json
Support array as root element in Postgresql JSON columns
2013-05-16 11:38:24 -07:00
Piotr Sarnacki
89f558c8c6 Check if APP_RAKEFILE is defined 2013-05-16 15:52:12 +02:00
Joel Cogen
2583e8ade8 Fix detection of engine in rake db:load_config
Broken by d1d7c86d0c8dcb7e75a87644b330c4e9e7d6c1c1
2013-05-16 12:06:08 +02:00
Aaron Patterson
99860582b2 tiny types should only be integers when the length is <= 1. fixes #10620 2013-05-15 18:03:10 -07:00
phinze
09a16ef178 add failing test exposing mysql adapter tinyint bug
in myself, a column with type TINYINT(N) where N > 1 can be used to
represent an integer, but the rails mysql adapter refuses to interpret
as anything but a boolean.
2013-05-15 17:50:55 -07:00
Aaron Patterson
dcc1267fee require things we need 2013-05-15 10:14:37 -07:00
Rafael Mendonça França
f22dbc62bd Merge pull request #10504 from kennyj/support_pg_91
Also should supports PostgreSQL 9.1 about extensions.
2013-05-15 10:14:04 -07:00
Rafael Mendonça França
5db56659f3 Merge pull request #10601 from Ichimonji10/fix-docs
Rewrite  `activerecord/RUNNING_UNIT_TESTS.rdoc`
2013-05-15 08:30:32 -07:00
Jeremy Audet
87ac19ebbe Rewrite activerecord/RUNNING_UNIT_TESTS
`RUNNING_UNIT_TESTS` is written in an unclear and confusing manner. This commit
attempts to correct that.

Thanks to zzak and vipulnsward for feedback.
2013-05-15 11:07:47 -04:00
kennyj
91c4d0b1e7 Remove unnecessary code, because this extension is created on demand in hstore_test.rb. 2013-05-15 12:47:49 +09:00
kennyj
349fc90996 Also support extensions in PostgreSQL 9.1, because this has been supported since 9.1. 2013-05-15 12:46:54 +09:00
Aaron Patterson
ba55276434 deprecating string based terminators 2013-05-14 16:03:09 -07:00
Alexey Noskov
9b66187622 Support array as root element in JSON 2013-05-14 17:44:32 +04:00
Aaron Patterson
d53b5f0739 Merge branch 'master' into normalizecb
* master: (61 commits)
  add tests for reset_calbacks
  Fixing build broken by this change
  Extract variable out of loop
  Updated comment to Rails 4
  Fixes NoMethodError: `alias_method_chain` when requiring just active_support/core_ext
  better error message when app name is not passed in `rails new`
  Code cleanup for ActionDispatch::Flash#call
  Fix typo: require -> requires
  Add CHANGELOG entry for #10576
  Merge pull request #10556 from Empact/deprecate-schema-statements-distinct
  Some editorial changes on the documentation.
  respond_to -> respond to in a message from AM::Lint
  specify that dom_(id|class) are deprecated in controllers, views are fine
  copy edits [ci skip]
  Fix class and method name typos
  Replace multi_json with json
  ruby -> Ruby
  Adding documentation to the automatic inverse_of finder.
  Improve CHANGELOG entry [ci kip]
  Call assume_migrated_upto_version on connection
  ...

Conflicts:
	activesupport/lib/active_support/callbacks.rb
2013-05-13 11:51:10 -07:00
Rafael Mendonça França
2519fb0e6d Merge pull request #10577 from vipulnsward/fix_method_typos
Fix class and method name typos
2013-05-12 11:29:17 -07:00
Rafael Mendonça França
8d3c67fbc4 Merge pull request #10556 from Empact/deprecate-schema-statements-distinct
Deprecate SchemaStatements#distinct, and make SchemaStatements#columns_for_distinct nodoc.
Conflicts:
	activerecord/CHANGELOG.md
2013-05-12 14:50:28 -03:00
Rafael Mendonça França
33062ee0f1 Some editorial changes on the documentation.
* Remove some autolinks
* Fix the rendered result
* Change sql to SQL

[ci skip]
2013-05-12 14:48:11 -03: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
Vipul A M
7493e0f78a Fix class and method name typos 2013-05-12 15:03:14 +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
Aaron Patterson
23122ab2d4 callbacks are wrapped with lambdas 2013-05-10 10:13:21 -07: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