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

[bug/spec fix] fix the error on NOT #65

Merged
merged 3 commits into from
Mar 31, 2021
Merged

Conversation

Dingying0410
Copy link
Contributor

@Dingying0410 Dingying0410 commented Mar 30, 2021

Summary

This will fix the build error introduced in #62. The build has passed.

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #65 (e12b031) into main (b1b590d) will increase coverage by 0.02%.
The diff coverage is 96.77%.

❗ Current head e12b031 differs from pull request most recent head 05be08d. Consider uploading reports for the commit 05be08d to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   97.34%   97.37%   +0.02%     
==========================================
  Files          34       34              
  Lines        2186     2209      +23     
==========================================
+ Hits         2128     2151      +23     
  Misses         58       58              
Impacted Files Coverage Δ
spec/cache_spec.rb 98.90% <95.00%> (+0.18%) ⬆️
lib/redis_memo/cache.rb 98.38% <100.00%> (+0.14%) ⬆️
spec/memoize_query_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1b590d...05be08d. Read the comment docs.

@Dingying0410 Dingying0410 marked this pull request as ready for review March 30, 2021 19:50
Copy link
Contributor

@donaldong donaldong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you help me better understand how this fixes the issue?

Looks like the build somehow passed in rails 6.1 and HEAD
https://github.com/chanzuckerberg/redis-memo/runs/2169583715

Should we expect that?

@Dingying0410
Copy link
Contributor Author

Dingying0410 commented Mar 30, 2021

re Donald's question, I think I know what is going on:

  1. there is a change of implementing NOT in rails 6.0 and rails 6.1, see https://bigbinary.com/blog/rails-6-deprecates-where-not-working-as-nor-and-will-change-to-nand-in-rails-6-1, and chained NOT is deprecated in 6.0 (but just a warning), and interpreted as NAND in rails 6.1 and before rials 6, it is interpreted as NOR
  2. all the rspecs in [feature] enable caching on queries with NOT #62 failed with
expected: [#<Site id: 1, a: 1, b: 1, not_memoized: 0, my_enum: "x">]
            got: []

this is expected

  1. in the specs here, in rails 6.0 it will show up a waring https://travis-ci.com/github/chanzuckerberg/redis-memo/jobs/495029171

I think this will not influence our features as we don't cache the chained NOT in either case, but might affect us in writing the specs.

I have a couple of solutions in mind:

  1. don't have the test case for Site.where.not(a: 1, b: 1) since it will be deprecated
  2. keep this test case, but only test it does not cache
  3. keep this test case, but have the rspec testing different scenario for gem versions, like this approach , I think this might only affect local tests? since we already tested different rails versions in CI

do you guys have any thoughts about supporting different rails versions?

@katyho @donaldong

@donaldong
Copy link
Contributor

Ah makes sense. Thanks for looking into this. To me, I have a slight preference over the 3rd approach since they are still valid rails usage in the earlier versions. We can check Rails.version too in rspec.

let!(:relation3_with_only_not) { Site.where.not(a: 2).where.not(b: 1) }
let!(:relation_with_not_and_other) { Site.where.not(a: 2).where(b: 1) }
# where.not(a: ..., b:...) relation is treated differently in Rails 6.0, Rails 6.1 and before Rails 6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is slightly confusing. The ones after L471 seem to be clearer to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed a bit, let me know if that is clear enough

redis-memo.gemspec Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
spec/memoize_query_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@donaldong donaldong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@Dingying0410 Dingying0410 merged commit ee26d55 into main Mar 31, 2021
@Dingying0410 Dingying0410 deleted the christina/fix_not_error branch March 31, 2021 17:31
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.

None yet

3 participants