activerecord-summarize 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbba2c0577555f891c1f860b76cc9f0194504d47d59922c8337afb9a1b3ab1a0
4
- data.tar.gz: 3c1945b1652a4305ec4df2d13a0c5a6966e308018d2b34c5c21e396f02a1e31c
3
+ metadata.gz: d491ee7730156f77105ec7df6bac79b6410fa97b3387816f103dee233b43df8d
4
+ data.tar.gz: f33be41270ab955fcf2bf9b227cc7c212ae3aa385786da3a5b424a3e1e707e47
5
5
  SHA512:
6
- metadata.gz: a2a9e27420e30861c5c713e757ae66ead1af9d5aa9e10b259620b10d9289652464fc561745e720bae100cbda1b265e9f551cfd1f05c78f53c8dae39bfd788c33
7
- data.tar.gz: 7e8632ae8ced794bdfb539624a64ebeef8d4a0a6568e3f625cca13b0d669365dd309981d351649c2af3a33f21c45e0fed2848853d581681dd0656d55b8163005
6
+ metadata.gz: 0d1f5308da4fc8b781e8dd5a69a10c671106acdb9b565c056d23b33114fc96f8d4ff9a60f3887b861f9142b2564c3f33f17d9e8ea52c212c27abbdacc861e2d6
7
+ data.tar.gz: 318bad930ac53001068e6e3396d921f71ff62c8a0899abe7a96a55d9dab59aa7e6e45c2cdc6e7a5f5ae60b67f18a47be79cb73ee29a85e1fac25a988c43dc47a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.3.1] - 2022-06-23
2
+
3
+ - **BUGFIX:** `with` didn't work correctly with a single argument. Embarassingly, both the time-traveling version of `with` and the trivial/fake one provided when `noop: true` is set had single argument bugs, and they were different bugs.
4
+ - **IMPROVEMENT:** Automated tests covering every `with` invocation style I can think of for both implementations and a number of new tests to confirm that `noop: true` produces the same results as (default) `noop: false`.
5
+ - **IMPROVEMENT:** After the initial release I forgot I had a CHANGELOG, and now I've back-filled it.
6
+
7
+ ## [0.3.0] - 2022-06-04
8
+
9
+ - **BUGFIX:** `.sum(:foo)` of no rows or of all-null values now returns 0 instead of failing (completing partial fix from 0.2.3)
10
+ - **BREAKING:** extremely unlikely to actually break anything, but `.count("distinct id")` now raises as `.distinct.count(:id)` already did. (AFAICT, by the nature of the techniques underlying `summarize`, `distinct` counts cannot be supported.)
11
+ - **IMPROVEMENT:** Automated tests covering basic functions and past problem areas.
12
+
13
+ ## [0.2.3] - 2022-05-01
14
+
15
+ - **BUGFIX:** Fix results for SQL `SUM(null)` (n.b., this turned out to be only a partial fix)
16
+ - **BUGFIX:** Support summarize with only one query (not often very useful, but it should work!)
17
+
18
+ ## [0.2.2] - 2022-04-29
19
+
20
+ - **BUGFIX:** Incorrect Arel generation when using `.where(*anything).sum` inside a `summarize` block
21
+
1
22
  ## [0.2.1] - 2022-02-17
2
23
 
3
24
  - Initial public release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-summarize (0.3.0)
4
+ activerecord-summarize (0.3.1)
5
5
  activerecord (>= 5.0)
6
6
 
7
7
  GEM
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
25
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
26
  `git ls-files -z`.split("\x0").reject do |f|
27
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci|vscode|standard)|appveyor)})
28
28
  end
29
29
  end
30
30
  spec.bindir = "exe"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Summarize
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -38,7 +38,7 @@ module ActiveRecord::Summarize
38
38
 
39
39
  def process(&block)
40
40
  # For noop, just yield the original relation and a transparent `with` proc.
41
- return yield(@relation, ->(*results, &block) { [*results].then(&block) }) if noop?
41
+ return yield(@relation, ChainableResult::SYNC_WITH) if noop?
42
42
  # Within the block, the relation and its future clones intercept calls to
43
43
  # `count` and `sum`, registering them and returning a ChainableResult via
44
44
  # summarize.add_calculation.
@@ -69,7 +69,7 @@ class ChainableResult
69
69
  def self.wrap(v, method = nil, *args, **opts, &block)
70
70
  method ||= block ? :then : :itself
71
71
  klass = case v
72
- when ChainableResult then return v # don't wrap, exit early
72
+ when ChainableResult then ChainableResult::Future
73
73
  when ::Array then ChainableResult::Array
74
74
  when ::Hash then ChainableResult::Hash
75
75
  else ChainableResult::Other
@@ -81,7 +81,13 @@ class ChainableResult
81
81
  ChainableResult.wrap(results.size == 1 ? results.first : results, :then, &block)
82
82
  end
83
83
 
84
+ def self.sync_with(*results, &block)
85
+ # Non-time-traveling, synchronous version of `with` for testing
86
+ (results.size == 1 ? results.first : results).then(&block)
87
+ end
88
+
84
89
  WITH = method(:with)
90
+ SYNC_WITH = method(:sync_with)
85
91
 
86
92
  def self.resolve_item(item)
87
93
  case item
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-summarize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Paine
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-04 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -46,7 +46,6 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".standard.yml"
50
49
  - CHANGELOG.md
51
50
  - Gemfile
52
51
  - Gemfile.lock
data/.standard.yml DELETED
@@ -1,5 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/testdouble/standard
3
- # ignore:
4
- # - 'lib/**/*':
5
- # - Layout/DotPosition