Commit Graph

4004 Commits

Author SHA1 Message Date
Ryuta Kamizono
501ae92a32 Only use BINARY for mysql case sensitive uniqueness check when column has a case insensitive collation. 2013-11-26 04:59:18 +09:00
Rafael Mendonça França
a6900a2073 Merge pull request #13034 from vipulnsward/some_typos
Fix some minor typos
2013-11-25 10:49:35 -08:00
Vipul A M
82de1eda7c Fix some minor typos [ci skip] 2013-11-26 00:13:35 +05:30
Yves Senn
7ccb482181 Merge pull request #13029 from akshay-vishnoi/documentation
`delgated` => `delegated`
2013-11-25 00:47:59 -08:00
Akshay Vishnoi
5a406ff42e delgated => delegated 2013-11-25 14:09:44 +05:30
Evgeny Li
c449a74e89 Fix validation on uniqueness of empty association 2013-11-22 22:22:34 +04:00
Yves Senn
e2fbec96d4 replace custom Time stubbing with travel and travel_to. 2013-11-21 17:29:53 +01:00
Jon Leighton
64b9e93bb5 Fix ActiveRecord::Relation#unscope
I'm pretty confused about the addition of this method. The documentation
says that it was intended to allow the removal of values from the
default scope (in contrast to #except). However it behaves exactly the
same as except: https://gist.github.com/jonleighton/7537008 (other than
having a slightly enhanced syntax).

The removal of the default scope is allowed by
94924dc32baf78f13e289172534c2e71c9c8cade, which was not a change we
could make until 4.1 due to the need to deprecate things. However after
that change #unscope still gives us nothing that #except doesn't already
give us.

However there *is* a desire to be able to unscope stuff in a way that
persists across merges, which would allow associations to be defined
which unscope stuff from the default scope of the associated model. E.g.

  has_many :comments, -> { unscope where: :trashed }

So that's what this change implements. I've also corrected the
documentation. I removed the guide references to #except as I think
unscope really supercedes #except now.

While we're here, there's also a potential desire to be able to write
this:

  has_many :comments, -> { unscoped }

However, it doesn't make sense and would not be straightforward to
implement. While with #unscope we're specifying exactly what we want to
be removed from the relation, with "unscoped" we're just saying that we
want it to not have some things which were added earlier on by the
default scope. However in the case of an association, we surely don't
want *all* conditions to be removed, otherwise the above would just
become "SELECT * FROM comments" with no foreign key constraint.

To make the above work, we'd have to somehow tag the relation values
which get added when evaluating the default scope in order to
differentiate them from other relation values. Which is way too much
complexity and therefore not worth it when most use cases can be
satisfied with unscope.

Closes #10643, #11061.
2013-11-20 22:23:16 +00:00
Yves Senn
da800614ca swap arguments for some assert_equal statements => expected, actual 2013-11-20 13:58:09 +01:00
Yves Senn
f83c9b10b4 use arel nodes to represent non-string order_values.
This fixes a bug when merging relations of different classes.

```
Given:
  Post.joins(:author).merge(Author.order(name: :desc)).to_sql

Before:
 SELECT "posts".* FROM "posts"
   INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
   ORDER BY "posts"."name" DESC

After:
 SELECT "posts".* FROM "posts"
   INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
   ORDER BY "authors"."name" DESC
```
2013-11-19 17:40:21 +01:00
Rafael Mendonça França
a7afceec3e Revert "Properly require database tasks so we have access to the raised constant"
This reverts commit fbcd46b1a0d255a34d29caa77bbd31c287446333.

This is not needed anymore. See 7280965
2013-11-19 13:08:06 -02:00
Rafael Mendonça França
728096542a Revert "Explicitly exit with status "1" for create and drop failures"
This reverts commit 22f80ae57b26907f662b7fd50a7270a6381e527e.

See
22f80ae57b (commitcomment-4640676)

Conflicts:
	activerecord/CHANGELOG.md
2013-11-19 13:07:28 -02:00
Yasuo Honda
d7c2958a03 Do not count query for all_constraints and all_tab_cols in Oracle 2013-11-18 11:59:36 +09:00
Yasuo Honda
8e3474bede Address test_merging_where_relations failure by adding order("posts.id") 2013-11-18 02:10:56 +09:00
Carlos Antonio da Silva
fbcd46b1a0 Properly require database tasks so we have access to the raised constant
Fix travis failures.
2013-11-17 14:22:24 -02:00
Rafael Mendonça França
c069e0fa34 Merge pull request #12918 from versioncontrol/rails-12866
Checks to see if the record contains the foreign_key to set the inverse automatically

Conflicts:
	activerecord/CHANGELOG.md
2013-11-16 18:28:03 -02:00
Edo Balvers
02ca5580bd Checks to see if the record contains the foreign_key to set the inverse automatically 2013-11-16 21:18:02 +01:00
Ryan Davis
456d308f47 Fix bad test order dependency between LoadAllFixturesTest#test_all_there and FoxyFixturesTest#test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same 2013-11-16 00:22:05 -08:00
Ryan Davis
8552791779 Fix bad test order dependency between test/cases/validations/i18n_generate_message_validation_test.rb and test/cases/validations/uniqueness_validation_test.rb 2013-11-16 00:12:12 -08:00
Aaron Patterson
d5dbc037c4 test should clean up after themselves 2013-11-15 14:36:15 -08:00
Aaron Patterson
314e2cc05b Merge pull request #12779 from dougbarth/dont_swallow_exceptions_during_transactional_statements_in_mysql
Don't swallow exceptions in transctional statements
2013-11-15 11:29:12 -08:00
Rafael Mendonça França
8c66623627 Merge pull request #12531 from iamvery/database-tasks-exit-status
Explicitly exit with status "1" for create and drop task failures

Conflicts:
	activerecord/CHANGELOG.md
2013-11-15 16:59:29 -02:00
Doug Barth
2b0406cedb Remove tests for not swallowing exceptions.
From PR, @tenderlove would prefer to not maintain these tests.
2013-11-15 10:29:30 -08:00
Kuldeep Aggarwal
a5d588875f added one test case and example for ActiveRecord::Base.to_param method 2013-11-15 20:05:17 +05:30
Carlos Antonio da Silva
6b84de4575 Fix test name [ci skip] 2013-11-14 23:45:30 -02:00
David Heinemeier Hansson
07996ebc50 Revert "Used Yield instead of block.call" -- this causes all of atom_feed_helper_test.rb to fail with "SystemStackError: stack level too deep".
This reverts commit d3a1ce1cdc60d593de1682c5f4e3230c8db9a0fd.
2013-11-14 15:31:27 -08:00
David Heinemeier Hansson
421c81bd18 Fix that eager loading of polymorphic associations did not work with association empty?/any? predicates any more (there is still a problem when select is applied to a relation, or if you try association#exists? -- but its easier to work around) 2013-11-14 14:43:14 -08:00
Javan Makhmali
633100b9e5 Addendum to #12891
* Fix incorrectly named tests
* Restore Object#to_param behavior
* Ensure param is derived from a squished and truncated string
2013-11-14 15:35:53 -05:00
Rafael Mendonça França
84961dc5df Merge pull request #12889 from kuldeepaggarwal/speed_ups
Used Yield instead of block.call
2013-11-14 11:29:28 -08:00
Kuldeep Aggarwal
d3a1ce1cdc Used Yield instead of block.call 2013-11-15 00:53:57 +05:30
Javan Makhmali
547999df25 Add AR::Base.to_param for convenient "pretty" URLs derived from a model's attribute or method. 2013-11-14 13:38:08 -05:00
Rafael Mendonça França
3d2e8cb71c Merge pull request #12772 from dmathieu/no_touching
Add No Touching
2013-11-13 13:37:40 -08:00
Yves Senn
c994e10862 fix weird Emacs auto indentation. [ci skip] 2013-11-13 17:56:44 +01:00
Yves Senn
f081edb1fe tests for merging Relations of different classes. 2013-11-13 17:41:26 +01:00
Yves Senn
742adce211 move Relation#merge tests into separate file. 2013-11-13 17:41:20 +01:00
Akira Matsuda
a99b81e44f Ensure that a column added in a test is being removed after all 2013-11-13 19:21:40 +09:00
Damien Mathieu
b32ba367f5 add #no_touching on ActiveRecord models 2013-11-13 08:42:38 +01:00
dm1try
dbb7ee1bfd Prevent the counter cache from being decremented twice
when destroying a record on a has_many :through association.
:destroy method has own counter_cache callbacks.
2013-11-11 19:53:02 +03:00
Yves Senn
07ae1e9b55 Unifies mysql and mysql2 casting of booleans. 2013-11-11 16:15:00 +01:00
Yves Senn
07790d5832 test cases to describe the MySQL boolean behavior. 2013-11-11 16:09:02 +01:00
Jay Hayes
22f80ae57b Explicitly exit with status "1" for create and drop failures
* A non-zero exit status allows subsequent shell commands to be chained
  together such as: `rake db:reset test:prepare && rspec && cap deploy`
  (if you're feeling brave :)
* Any exceptions raised during the `create` and `drop` tasks are caught
  in order to print a "pretty" message to the user. Unfortunately doing
  so prevents rake from aborting with a non-zero exit status to the shell.
* Therefore we re-raise the exceptions after the "pretty" message and
  re-catch them in the task.
* From the task we explicitly exit with a non-zero status. This method
  was chosen (rather than just letting rake fail from the exception) so
  that the backtrace is suppressed and the output to stderr is
  unchanged.
* Update activerecord CHANGELOG
2013-11-11 07:54:30 -06:00
Akira Matsuda
331c59f47c Do not count "SHOW CREATE TABLE" queries when testing against mysql 2013-11-11 22:06:27 +09:00
Akira Matsuda
3ce9e43bc3 Avoid sorting an Array including objects from different Classes
addresses "ArgumentError: comparison of VerySpecialComment with SpecialComment failed" in ActiveRecord::DelegationRelationTest#test_#sort!_delegation_is_deprecated
2013-11-11 19:53:54 +09:00
Akira Matsuda
48b10134a5 Load test fixtures where data are needed
Without this, some tests here were not actually testing anything.
2013-11-11 19:53:54 +09:00
Yves Senn
f5802708db Merge pull request #12834 from dredozubov/has_one_association_replacement
Fixes problem with replacing has_one association record with itself
2013-11-11 02:26:23 -08:00
Denis Redozubov
3ed5642e69 Fixes problem with replacing has_one association record with itself 2013-11-11 14:19:12 +04:00
Akira Matsuda
9222928dfb A tiny grammatical fix
[ci skip]
2013-11-11 19:14:42 +09:00
Rafael Mendonça França
98cff28d3f Merge pull request #12749 from iantropov/issue_5303
Add test for ActiveRecord::Relation YAML serialization, for #5303 issue
2013-11-10 23:14:23 -02:00
Yves Senn
140c0c8881 use complete Relation API and not only Model.all.merge!. 2013-11-09 22:02:46 +01:00
Arun Agrawal
539ce8b683 Changed message for Model.inspect
(No database connection) sounds not be
able to connect database.

see more #12804
2013-11-09 20:57:09 +01:00