Jon Leighton
b658cf1198
Deprecate ActiveRecord::Base.scoped.
...
It doesn't serve much purpose now that ActiveRecord::Base.all returns a
Relation.
The code is moved to active_record_deprecated_finders.
2012-07-27 17:27:47 +01:00
Jon Leighton
3803fcce26
Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.
2012-07-20 19:00:46 +01:00
Jon Leighton
e1cfa6e070
Convert association macros to the new syntax
2012-07-20 14:14:51 +01:00
Jon Leighton
0a12a5f816
Deprecate eager-evaluated scopes.
...
Don't use this:
scope :red, where(color: 'red')
default_scope where(color: 'red')
Use this:
scope :red, -> { where(color: 'red') }
default_scope { where(color: 'red') }
The former has numerous issues. It is a common newbie gotcha to do
the following:
scope :recent, where(published_at: Time.now - 2.weeks)
Or a more subtle variant:
scope :recent, -> { where(published_at: Time.now - 2.weeks) }
scope :recent_red, recent.where(color: 'red')
Eager scopes are also very complex to implement within Active
Record, and there are still bugs. For example, the following does
not do what you expect:
scope :remove_conditions, except(:where)
where(...).remove_conditions # => still has conditions
2012-03-21 22:18:18 +00:00
Jon Leighton
a7e19b30ca
Add interpolation of association conditions back in, in the form of proc { ... } rather than instance_eval-ing strings
2011-02-14 01:40:31 +00:00
Jon Leighton
3103296a61
Let AssociationCollection#find use #scoped to do its finding. Note that I am removing test_polymorphic_has_many_going_through_join_model_with_disabled_include, since this specifies different behaviour for an association than for a regular scope. It seems reasonable to expect scopes and association proxies to behave in roughly the same way rather than having subtle differences.
2011-01-03 16:24:31 -08:00
José Valim
2ea1d684d9
Refactor new callbacks and AR implementation.
...
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
Pratik Naik
45e6f19925
Revert "Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]""
...
This reverts commit 80f1f863cd
.
The feature doesn't work on Postgres, so don't test it on Postgres.
Also, Postgres compatibility is irrelevant to the ticket/patch in question.
2009-07-01 00:02:00 +01:00
Yehuda Katz + Carl Lerche
80f1f863cd
Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]"
...
This reverts commit 4851ca9e13
.
The tests do not pass for postgresql.
2009-06-22 12:04:02 -07:00
Patrick Joyce
4851ca9e13
Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [ #2118 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-06-21 22:07:23 +01:00
Pratik Naik
6513dde490
Fix tests for sqlite3 3.6.xx
2009-04-21 13:06:26 +01:00
miloops
97403ad5fd
Add :having option to find, to use in combination with grouped finds. Also added to has_many and has_and_belongs_to_many associations.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1028 state:committed]
2008-12-01 20:22:31 +01:00
Tarmo Tänav
52ac9d0444
Fixed ordering in test_find_in_association_with_custom_finder_sql_and_multiple_interpolations
2008-08-22 10:39:45 +03:00
Jeremy Kemper
dfa786631b
Introduce the :readonly option to all associations. Records from the association cannot be saved. Closes #11084 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-13 06:32:50 +00:00
Jeremy Kemper
43b81d01d0
move assets and models
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:27:03 +00:00