Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip some CalculationsTests #64

Merged
merged 2 commits into from
Apr 15, 2020
Merged

Conversation

alimi
Copy link
Contributor

@alimi alimi commented Apr 13, 2020

Most of the skipped tests fail against CockroachDB because ActiveRecord strips out the query order clause from group by queries making it impossible to guarantee the results order. These tests pass against databases like PostgreSQL because they'll inherently order by the group by clause. This appears to be a bug in ActiveRecord, see rails/rails#38936.

The other test, :test_group_by_with_order_by_virtual_count_attribute, fails because ordering with virtual count attributes doesn't work against CockroachDB.

For example, here’s a posts table and it has a type column.

activerecord_unittest=# select posts.type, count(*) from posts group by posts.type;
    type     | count 
-------------+-------
 Post        |     9
 StiPost     |     1
 SpecialPost |     1
(3 rows)

If I run a query like SELECT MAX(posts.comments_count) AS maximum_comments_count, posts.type AS posts_type FROM posts GROUP BY posts.type ORDER BY posts.count ASC limit 2; against PostgreSQL, it works.

activerecord_unittest=# SELECT  MAX(posts.comments_count) AS maximum_comments_count, posts.type AS posts_type FROM posts GROUP BY posts.type ORDER BY posts.count ASC limit 2;
 maximum_comments_count | posts_type  
------------------------+-------------
                      2 | StiPost
                      1 | SpecialPost
(2 rows)

When I run the query against CockroachDB, it blows up because posts.count isn’t recognized in the ORDER BY clause.

root@localhost:26258/activerecord_unittest> SELECT  MAX(posts.comments_count) AS maximum_comments_count, posts.type AS posts_type FROM posts GROUP BY posts.type ORDER BY posts.count ASC limit 2;
ERROR: column "posts.count" does not exist

Is this a know limitation in CockroachDB? I’m not seeing it documented anywhere (it’s kinda hard to search for).

  * Ordering with virtual count attributes is not supported against CockroachDB
  * The test fails because ActiveRecord strips out the query order clause making
    it impossible to guarantee the results order. See bug issue
    rails/rails#38936.
@alimi
Copy link
Contributor Author

alimi commented Apr 14, 2020

@rafiss opened cockroachdb/cockroach#47477 for the ordering with virtual count attributes failure.

@apantel
Copy link
Contributor

apantel commented Apr 14, 2020

This is fine, just clean up the commits.

@alimi
Copy link
Contributor Author

alimi commented Apr 14, 2020

What do you mean by clean up the commits?

@apantel apantel merged commit 3f8e11c into cockroachdb:master Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants