Commit Graph

61 Commits

Author SHA1 Message Date
Jon Leighton
13b3c77e39 Add Relation#find_by and Relation#find_by! 2012-03-30 12:52:29 +01:00
Guillermo Iguaran
bb2e2d8cb6 CHANGELOG entry for AR#slice 2012-03-29 17:50:06 -05: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
Carlos Antonio da Silva
dde3058c3a Expand changelog and upgrading rails guide with IdentityMap info 2012-03-13 20:08:55 -03:00
Carlos Antonio da Silva
a8dd21d8b4 Remove IdentityMap 2012-03-13 20:08:54 -03:00
Andrew White
eee32af45e Add dynamic find_or_create_by_{attribute}! method. 2012-03-12 14:16:19 +00:00
Rafael Mendonça França
d804790634 Fix my name in the CHANGELOG to follow the convention
Also add missing entries and use the formating convention
2012-03-09 00:54:21 -03:00
Vijay Dev
8a714c4d80 fix incorrect changelog headings [ci skip].
Last commit message should not have said 'Rails 4' either
2012-03-09 02:30:49 +05:30
Vijay Dev
db6542178c changelog updates for Rails 4 [ci skip] 2012-03-09 02:22:17 +05:30
kennyj
aa9b64790b Update CHANGELOG to fix wrong extension. 2012-03-08 20:07:44 +09:00
Aaron Patterson
447ecb08ca Merge pull request #5162 from kennyj/schema_cache_dump
[Proposal] Schema cache dump
2012-03-07 16:44:50 -08:00
claudiob
05c6caf48c Add release dates to documentation
Set "March 1, 2012" as the release date for 3.2.2, 3.1.4, 3.0.12
2012-03-01 11:20:03 -08:00
kennyj
46c12172fe Add entry for schema cache dump to CHANGELOG.md. 2012-03-01 01:22:42 +09:00
Paco Guzman
152a393d4f Update changelogs with rails 3.0-stable branch info 2012-02-25 13:50:08 +01:00
Josef Šimánek
b4b2f5d8e4 Update activerecord/CHANGELOG.md 2012-02-18 18:29:48 +01:00
Marcelo Silveira
d70e0236df Added where option to add_index to support postgresql partial indices
The `add_index` method now supports a `where` option that receives a
string with the partial index criteria.

    add_index(:accounts, :code, :where => "active")

    Generates

    CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active
2012-02-09 01:20:52 -02:00
Juanjo Bazán
8270e4a8ce Added none query method to return zero records.
And added NullRelation class implementing the null object pattern for the `Relation` class.
2012-01-31 19:50:09 +01:00
Manoj
336ff8a97e has_many/has_one, :dependent => :restrict, deprecation added. 2012-01-29 15:28:22 +05:30
Rafael Mendonça França
080bd83df9 Add create_join_table migration helper to create HABTM join tables 2012-01-27 15:34:53 -02:00
Matt Bridges
abb1423a8d Fixed small typo in ActveRecord/CHANGELOG.md 2012-01-26 08:51:41 -06:00
Xavier Noria
9725c0cb34 syncs 3-2-stable CHANGELOGs in master 2012-01-26 13:12:04 +01:00
claudiob
6d426b1035 Add release date of Rails 3.2.0 to documentation 2012-01-26 01:53:38 -08:00
Aaron Patterson
522c0fdb55 The primary key is always initialized in the @attributes hash to nil (unless
another value has been specified).
2012-01-25 14:42:22 -08:00
Olek Janiszewski
7afbc89c37 Add ActiveRecord::Base#with_lock
Add a `with_lock` method to ActiveRecord objects, which starts
a transaction, locks the object (pessimistically) and yields to the block.
The method takes one (optional) parameter and passes it to `lock!`.

Before:

    class Order < ActiveRecord::Base
      def cancel!
        transaction do
          lock!
          # ... cancelling logic
        end
      end
    end

After:

    class Order < ActiveRecord::Base
      def cancel!
        with_lock do
          # ... cancelling logic
        end
      end
    end
2012-01-18 23:23:41 +01:00
Jon Leighton
8c0c0838cf Make it more explicit that the feature is deprecated, not removed. 2012-01-16 21:35:21 +00:00
Jon Leighton
a2dab46cae Deprecate inferred JOINs with includes + SQL snippets.
See the CHANGELOG for details.

Fixes #950.
2012-01-16 21:32:12 +00:00
Vijay Dev
84d633a0b3 Merge pull request #4387 from Karunakar/releasenotes
Added the release dates for rails 3.1.1, rails 3.1.2, rails 3.1.3
2012-01-12 11:23:51 -08:00
Santiago Pastorino
838d30f182 Add CHANGELOG entry 2012-01-11 23:52:57 -02:00
Aaron Patterson
f82e244a80 dropping support for schema_info. 2012-01-10 10:54:10 -08:00
Karunakar (Ruby)
e634d25ac8 Added the release dates for rails 3.1.1, rails 3.1.2, rails 3.1.3 2012-01-08 23:26:46 +05:30
Aaron Patterson
6769293988 connections must be checked in at the end of a thread 2011-12-30 11:37:21 -08:00
Jon Leighton
00318e9bdf Add some doc for ActiveRecord::Model 2011-12-24 11:28:03 +00:00
Aaron Patterson
96838b5192 can create hstore records via AR API 2011-12-20 14:04:50 -06:00
Aaron Patterson
776af48acb PostgreSQL hstore types are automatically deserialized from the database. 2011-12-20 14:04:50 -06:00
Vijay Dev
10a5497f2e NullStore cache belongs in Active Support 2011-12-20 23:44:47 +05:30
Brian Durand
04d5eae4e8 Add ActiveSupport::Cache::NullStore to expose caching interface without actually caching for development and test environments. 2011-12-12 13:40:29 -06:00
Piotr Sarnacki
35a1744a45 Allow to run migrations with given scope, with SCOPE=<scope>
Scope in migrations can be defined by adding suffix in filename,
like: 01_a_migration.blog.rb. Such migration have blog scope.

Scope is automatically added while copying migrations from engine,
so if you want to revert all of the migrations from given engine,
you can just run db:migrate with SCOPE, like:

    rake db:migrate SCOPE=blog
2011-12-09 22:00:51 +01:00
Xavier Noria
de24ed9f2d removes the convenience instance version of AR::Base.silence_auto_explain
Rationale: As discussed with José and Jon, this convenience
shortcut is not clearly justified and it could let the user
thing the disabled EXPLAINs are related to the model instance
rather than being globally disabled.
2011-12-03 14:26:34 +01:00
Xavier Noria
0be5adaedf implements AR::Base(.|#)silence_auto_explain 2011-12-02 11:16:26 -08:00
Xavier Noria
0306f82e0c implements automatic EXPLAIN logging for slow queries 2011-12-02 04:35:43 -08:00
David Heinemeier Hansson
83d29a283c Revert "Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack"
Needless indirection with no added value.

This reverts commit 535853e83b9092078035a5abb2aa242fba815c05.
2011-12-01 20:45:47 +01:00
David Heinemeier Hansson
535853e83b Added ActiveRecord::Base#last_modified to work with the new fresh_when/stale? conditional get methods from Action Pack 2011-12-01 19:47:14 +01:00
Bogdan Gusiev
a382d60f6a ActiveRecord::Relation#pluck method 2011-11-30 11:03:00 +02:00
Aaron Patterson
0e2477b602 Automatic closure of connections in threads is deprecated. For example
the following code is deprecated:

Thread.new { Post.find(1) }.join

It should be changed to close the database connection at the end of
the thread:

Thread.new {
  Post.find(1)
  Post.connection.close
}.join

Only people who spawn threads in their application code need to worry
about this change.
2011-11-29 15:04:41 -08:00
Jon Leighton
f3c84dc316 Deprecate set_locking_column in favour of self.locking_column= 2011-11-29 20:13:37 +00:00
Jon Leighton
1a474cc8e4 Deprecate set_primary_key in favour of self.primary_key= 2011-11-29 20:13:37 +00:00
Jon Leighton
7af719e81c Deprecate set_sequence_name in favour of self.sequence_name= 2011-11-29 20:13:37 +00:00
Jon Leighton
34609d67b4 Deprecate set_inheritance_column in favour of self.inheritance_column= 2011-11-29 20:13:36 +00:00
Jon Leighton
0b72a04d0c Deprecate set_table_name in favour of self.table_name= or defining your own method. 2011-11-29 20:13:36 +00:00
Jon Leighton
2169603385 Merge pull request #3636 from joshsusser/master
association methods are now generated in modules
2011-11-29 10:09:42 -08:00