Skip to content

Instantly share code, notes, and snippets.

@rzane
Last active February 17, 2019 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rzane/9a395056cfa816c642b3bfd9ecd1db20 to your computer and use it in GitHub Desktop.
Save rzane/9a395056cfa816c642b3bfd9ecd1db20 to your computer and use it in GitHub Desktop.
Run options:
include {:focus=>true}
exclude {:compat=>true}
All examples were filtered out; ignoring {:focus=>true}
Running with ActiveRecord 5.2.1
..........................................................................................................................................................................F..............F......F..F...F....FFF.................F............F....F........F.......FF...FF............
Failures:
1) #grouping groups on an aliased association
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT COUNT("posts_authors"."id") FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
GROUP BY "posts_authors"."author_id"
got:
SELECT COUNT("posts"."id") FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
GROUP BY "posts"."author_id"
(compared using ==)
# ./spec/integration/grouping_spec.rb:29:in `block (2 levels) in <top (required)>'
2) #joining when joining implicitly correctly aliases when joining the same table twice
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "posts" "parents_posts" ON "parents_posts"."id" = "posts"."parent_id"
LEFT OUTER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "parents_posts"."author_id"
WHERE ("authors"."name" = 'Rick' OR "authors_posts"."name" = 'Flair')
got:
SELECT "posts".* FROM "posts"
LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "posts" "parents_posts" ON "parents_posts"."id" = "posts"."parent_id"
LEFT OUTER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "parents_posts"."author_id"
WHERE ("authors"."name" = 'Rick' OR "authors"."name" = 'Flair')
(compared using ==)
# ./spec/integration/joining_spec.rb:120:in `block (3 levels) in <top (required)>'
3) #joining when joining implicitly nested joins outer joins
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors"."id"
got:
SELECT "posts".* FROM "posts"
LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors"."id"
(compared using ==)
# ./spec/integration/joining_spec.rb:155:in `block (4 levels) in <top (required)>'
4) #joining when joining implicitly nested joins outer joins only the specified associations
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors"."id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors"."id"
(compared using ==)
# ./spec/integration/joining_spec.rb:173:in `block (4 levels) in <top (required)>'
5) #joining when joining implicitly nested joins joins a through association and then back again
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
LEFT OUTER JOIN "authors" "authors_posts_join" ON "authors_posts_join"."id" = "posts_authors"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors_posts_join"."id"
INNER JOIN "posts" "posts_comments" ON "posts_comments"."id" = "comments"."post_id"
INNER JOIN "authors" "authors_posts_join_2" ON "authors_posts_join_2"."id" = "posts_comments"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors_posts_join_2"."id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
INNER JOIN "authors" "authors_posts_join" ON "authors_posts_join"."id" = "posts_authors"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors_posts_join"."id"
INNER JOIN "posts" "posts_comments" ON "posts_comments"."id" = "comments"."post_id"
INNER JOIN "authors" "authors_posts_join_2" ON "authors_posts_join_2"."id" = "posts_comments"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors_posts_join_2"."id"
(compared using ==)
# ./spec/integration/joining_spec.rb:200:in `block (4 levels) in <top (required)>'
6) #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes through joins
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
INNER JOIN "authors" "authors_posts_join" ON "authors_posts_join"."id" = "posts_authors"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors_posts_join"."id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors_2" ON "posts_authors_2"."author_id" = "authors_posts"."id"
LEFT OUTER JOIN "authors" "authors_posts_join_2" ON "authors_posts_join_2"."id" = "posts_authors_2"."author_id"
LEFT OUTER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors_posts_join_2"."id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
INNER JOIN "authors" "authors_posts_join" ON "authors_posts_join"."id" = "posts_authors"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors_posts_join"."id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors_2" ON "posts_authors_2"."author_id" = "authors_posts"."id"
INNER JOIN "authors" "authors_posts_join_2" ON "authors_posts_join_2"."id" = "posts_authors_2"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors_posts_join_2"."id"
(compared using ==)
# ./spec/integration/joining_spec.rb:234:in `block (5 levels) in <top (required)>'
7) #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes incremental outer joins
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors_posts"."id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors_posts"."id"
(compared using ==)
# ./spec/integration/joining_spec.rb:240:in `block (5 levels) in <top (required)>'
8) #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes incremental outer joins (in any order)
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors"."id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors"."id"
INNER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "posts"."author_id"
(compared using ==)
# ./spec/integration/joining_spec.rb:246:in `block (5 levels) in <top (required)>'
9) #ordering orders on an aliased table
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
ORDER BY "posts_authors"."id"
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
ORDER BY "posts"."id"
(compared using ==)
# ./spec/integration/ordering_spec.rb:46:in `block (2 levels) in <top (required)>'
10) #selecting selects on an aliased table
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts_authors"."id" FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
got:
SELECT "posts"."id" FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
(compared using ==)
# ./spec/integration/selecting_spec.rb:44:in `block (2 levels) in <top (required)>'
11) BabySqueel::ActiveRecord::Base#sifter yield the root table to the block when arity is given
Failure/Error: expect(relation).to match_sql_snapshot(variants: ['5.2'])
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors"."id"
WHERE "author_comments_posts"."id" > 1
got:
SELECT "posts".* FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors"."id"
WHERE "comments"."id" > 1
(compared using ==)
# ./spec/integration/sifting_spec.rb:45:in `block (2 levels) in <top (required)>'
12) #when_having adds a having clause with an aliased table
Failure/Error: expect(relation).to match_sql_snapshot(variants: ['4.2', '5.2'])
expected:
SELECT COUNT("posts_authors"."id") FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
GROUP BY "posts_authors"."id"
HAVING COUNT("posts_authors"."id") > 5
got:
SELECT COUNT("posts"."id") FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
GROUP BY "posts"."id"
HAVING COUNT("posts"."id") > 5
(compared using ==)
# ./spec/integration/when_having_spec.rb:35:in `block (2 levels) in <top (required)>'
13) #where.has wheres on an aliased association
Failure/Error: expect(relation).to match_sql_snapshot(variants: ['5.2'])
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
WHERE "posts_authors"."id" > 0
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
WHERE "posts"."id" > 0
(compared using ==)
# ./spec/integration/where_chain_spec.rb:61:in `block (2 levels) in <top (required)>'
14) #where.has wheres on an aliased association with through
Failure/Error: expect(relation).to match_sql_snapshot(variants: ['5.2'])
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors"."id"
WHERE "author_comments_posts"."id" > 0
got:
SELECT "posts".* FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" "author_comments_posts" ON "author_comments_posts"."author_id" = "authors"."id"
WHERE "comments"."id" > 0
(compared using ==)
# ./spec/integration/where_chain_spec.rb:69:in `block (2 levels) in <top (required)>'
15) #where.has wheres on an alias with outer join
Failure/Error: expect(relation).to match_sql_snapshot
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
LEFT OUTER JOIN "comments" ON "comments"."author_id" = "authors"."id"
WHERE "comments"."id" IN (1, 2) AND "authors"."name" = 'Joe'
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "comments" ON "comments"."author_id" = "authors"."id"
WHERE "comments"."id" IN (1, 2) AND "authors"."name" = 'Joe'
(compared using ==)
# ./spec/integration/where_chain_spec.rb:101:in `block (2 levels) in <top (required)>'
16) #where.has wheres on an alias with a function
Failure/Error: expect(relation).to match_sql_snapshot(variants: ['5.2'])
expected:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
WHERE coalesce("posts_authors"."id", 1) > 0
got:
SELECT "posts".* FROM "posts"
INNER JOIN "authors" ON "authors"."id" = "posts"."author_id"
INNER JOIN "posts" "posts_authors" ON "posts_authors"."author_id" = "authors"."id"
WHERE coalesce("posts"."id", 1) > 0
(compared using ==)
# ./spec/integration/where_chain_spec.rb:109:in `block (2 levels) in <top (required)>'
Finished in 0.26406 seconds (files took 0.80974 seconds to load)
278 examples, 16 failures
Failed examples:
rspec ./spec/integration/grouping_spec.rb:24 # #grouping groups on an aliased association
rspec ./spec/integration/joining_spec.rb:114 # #joining when joining implicitly correctly aliases when joining the same table twice
rspec ./spec/integration/joining_spec.rb:152 # #joining when joining implicitly nested joins outer joins
rspec ./spec/integration/joining_spec.rb:170 # #joining when joining implicitly nested joins outer joins only the specified associations
rspec ./spec/integration/joining_spec.rb:197 # #joining when joining implicitly nested joins joins a through association and then back again
rspec ./spec/integration/joining_spec.rb:229 # #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes through joins
rspec ./spec/integration/joining_spec.rb:237 # #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes incremental outer joins
rspec ./spec/integration/joining_spec.rb:243 # #joining when joining implicitly duplicate prevention when given a DSL join with an Active Record join dedupes incremental outer joins (in any order)
rspec ./spec/integration/ordering_spec.rb:41 # #ordering orders on an aliased table
rspec ./spec/integration/selecting_spec.rb:39 # #selecting selects on an aliased table
rspec ./spec/integration/sifting_spec.rb:40 # BabySqueel::ActiveRecord::Base#sifter yield the root table to the block when arity is given
rspec ./spec/integration/when_having_spec.rb:29 # #when_having adds a having clause with an aliased table
rspec ./spec/integration/where_chain_spec.rb:56 # #where.has wheres on an aliased association
rspec ./spec/integration/where_chain_spec.rb:64 # #where.has wheres on an aliased association with through
rspec ./spec/integration/where_chain_spec.rb:96 # #where.has wheres on an alias with outer join
rspec ./spec/integration/where_chain_spec.rb:104 # #where.has wheres on an alias with a function
Coverage report generated for RSpec to /Users/rzane/Workspace/baby_squeel/coverage. 497 / 513 LOC (96.88%) covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment