Thanks for your review. At first I was trying to use just `count` but it works as follows. `count` actually returns a Hash.

- Test case `count` only
```ruby
+      assert_equal 3, authors(:david).posts.merge(posts_with_special_comments_with_ratings).count
```

```ruby
$ ARCONN=postgresql  ruby -Itest test/cases/relation_test.rb -n test_relation_merging_with_merged_joins
Using postgresql
Run options: -n test_relation_merging_with_merged_joins --seed 3142

# Running tests:

F

Finished tests in 0.161776s, 6.1814 tests/s, 6.1814 assertions/s.

  1) Failure:
ActiveRecord::RelationTest#test_relation_merging_with_merged_joins [test/cases/relation_test.rb:185]:
Expected: 3
  Actual: {2=>1, 4=>1, 5=>1}

1 tests, 1 assertions, 1 failures, 0 errors, 0 skips
```

- debug.log

```ruby
  Author Load (1.6ms)  SELECT "authors".* FROM "authors" WHERE "authors"."id" = $1 LIMIT 1  [["id", 1]]
   (1.9ms)  SELECT COUNT(DISTINCT "posts"."id") AS count_id, posts.id AS posts_id FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" AND "comments"."type" IN ('SpecialComment', 'SubSpecialComment') LEFT OUTER JOIN "ratings" ON "ratings"."comment_id" = "comments"."id" WHERE "posts"."author_id" = $1 AND "comments"."type" IN ('SpecialComment', 'SubSpecialComment') GROUP BY posts.id  [["author_id", 1]]
```

- psql -d activerecord_unittest ( bind variable is replaced to 1) All adapters shows this result.

```sql
activerecord_unittest=# SELECT COUNT(DISTINCT "posts"."id") AS count_id, posts.id AS posts_id FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" AND "comments"."type" IN ('SpecialComment', 'SubSpecialComment') LEFT OUTER JOIN "ratings" ON "ratings"."comment_id" = "comments"."id" WHERE "posts"."author_id" = 1 AND "comments"."type" IN ('SpecialComment', 'SubSpecialComment') GROUP BY posts.id ;
 count_id | posts_id
----------+----------
        1 |        2
        1 |        4
        1 |        5
(3 rows)

activerecord_unittest=#
```