Skip to content

Conversation

shmax
Copy link
Contributor

@shmax shmax commented Oct 3, 2023

Another subtle fix. Apparently, rails does not throw an exception if you do a where with an empty array. Both of these should return an empty array, not throw:

Author::where(['author_id IN(?)', []])->to_a();
Author::where(['author_id' => []])->to_a();

Rails optimize this under the hood by just doing an always-false clause, ie:

WHERE 1=0

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #110 (399a14e) into master (d135bd1) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              master      #110   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       936       937    +1     
===========================================
  Files             34        34           
  Lines           2349      2349           
===========================================
  Hits            2349      2349           
Files Coverage Δ
lib/WhereClause.php 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@shmax shmax merged commit 7fd55a4 into master Oct 3, 2023
@shmax shmax deleted the fix-bound-var branch October 24, 2023 06:15
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.

1 participant