1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
Francesco Rodriguez aa202adf6c Count returns 0 without querying if parent is not saved
Patches `CollectionAssociation#count` to return 0 without querying
if the parent record is new. Consider the following code:

    class Account
      has_many :dossiers
    end

    class Dossier
      belongs_to :account
    end

    a = Account.new
    a.dossiers.build

    # before patch
    a.dossiers.count
    # SELECT COUNT(*) FROM "dossiers" WHERE "dossiers"."account_id" IS NULL
    # => 0

    # after
    a.dosiers.count # fires without sql query
    # => 0

Fixes #1856.
2012-10-03 18:02:14 -05:00
..
active_record/connection_adapters Ensure disconnecting or reconnecting resets the transaction state 2012-09-15 00:03:04 +01:00
assets
cases Count returns 0 without querying if parent is not saved 2012-10-03 18:02:14 -05:00
fixtures test cleanup, remove ruby_type because it's no longer needed 2012-09-03 20:38:14 +02:00
migrations
models fix warning: method redefined 2012-10-02 13:32:54 -03:00
schema Fix reset_counters() crashing on has_many :through associations. 2012-10-02 23:49:32 +08:00
support Fix annoy warning, when executing testcase. 2012-09-11 00:17:08 +09:00
.gitignore
config.example.yml Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests. 2012-07-16 09:55:20 -07:00
config.rb