activerecord-summarize 0.5.0 → 0.5.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: d3349ef226e79ac7b8182798fbe3f0966a94bd29a5ec31202fe14c74e681bc68
4
- data.tar.gz: f257baecb4562c791d0d7648f45ec2549e1ae6faff2cfcd386d95a5e68fb233a
3
+ metadata.gz: f469f566e328d4cc697d23295d95c477f6eb66c5d9246874b36bc59b5fbdcac0
4
+ data.tar.gz: 7a7315482f217384462c869796531e1ea27511ba1787f435aec1eed754601506
5
5
  SHA512:
6
- metadata.gz: fdf0dece89a7d1db578414a1682adb956e8a973c7d575b7d589d0645ef906bdba2f9d849a1833fd1cc10a7b6f1e105c2c36b54532624005d67d8501e1e03aa13
7
- data.tar.gz: a21a8e232e86706283954d4690b99c824c80b3521337c2dba10dc3f415f295844670f6d0c4ac94d7a0a8fa58c5fe408a07a64b3d31b65f20086a1d6920409382
6
+ metadata.gz: 66a61050cec2736eed06d01b5889f85259e0625daa530376fb840f02cb93a041483f335bda4614d2925b9b4d1ae22f811d8fa5d005dad82d559bd1a5d64f0bb5
7
+ data.tar.gz: b3f3e98e768a019f4c2a32c06d61fb84a50fcbc9f6866df35c1c254ee7d8feb2fd300a286a33cefd6407d12f8e67353348e7e600290ccfb2ae192e9dffd9fd9b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.5.1] - 2023-08-16
2
+
3
+ - **BUGFIX:** Starting with version 7.0.5, the behavior of ActiveRecord's `pluck` changed: when you pluck multiple values with the same aggregate function (e.g., `sum`), in PostgreSQL, the data type of the last such value is now applied to all such values, though they used to be inferred correctly. Our solution is to add an explicit alias to each result column.
4
+
1
5
  ## [0.5.0] - 2023-05-14
2
6
 
3
7
  - **FEATURE:** Your `summarize` blocks won't need to accept the proc second argument as often, because `ChainableResult` methods will also resolve their arguments. E.g., `query.summarize {|q| @mult = q.sum(:a) * q.sum(:b) }` now works, where previously you would have needed to write `query.summarize {|q,with| @mult = with[q.sum(:a),q.sum(:b)] {|a,b| a * b } }`.
data/Gemfile CHANGED
@@ -9,5 +9,6 @@ gem "rake", "~> 13.0"
9
9
  gem "minitest", "~> 5.0"
10
10
  gem "standard", "~> 1.3"
11
11
 
12
- gem "activerecord", "7.0.3"
13
- gem "sqlite3", "1.4.2"
12
+ gem "activerecord", "7.0.7"
13
+ gem "sqlite3", "1.6.3"
14
+ gem "pg", "~> 1.5"
data/Gemfile.lock CHANGED
@@ -1,67 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-summarize (0.5.0)
4
+ activerecord-summarize (0.5.1)
5
5
  activerecord (>= 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.3)
11
- activesupport (= 7.0.3)
12
- activerecord (7.0.3)
13
- activemodel (= 7.0.3)
14
- activesupport (= 7.0.3)
15
- activesupport (7.0.3)
10
+ activemodel (7.0.7)
11
+ activesupport (= 7.0.7)
12
+ activerecord (7.0.7)
13
+ activemodel (= 7.0.7)
14
+ activesupport (= 7.0.7)
15
+ activesupport (7.0.7)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
20
  ast (2.4.2)
21
- concurrent-ruby (1.1.10)
22
- i18n (1.10.0)
21
+ concurrent-ruby (1.2.2)
22
+ i18n (1.14.1)
23
23
  concurrent-ruby (~> 1.0)
24
- minitest (5.15.0)
25
- parallel (1.21.0)
26
- parser (3.1.1.0)
24
+ json (2.6.3)
25
+ language_server-protocol (3.17.0.3)
26
+ lint_roller (1.1.0)
27
+ minitest (5.19.0)
28
+ parallel (1.23.0)
29
+ parser (3.2.2.3)
27
30
  ast (~> 2.4.1)
31
+ racc
32
+ pg (1.5.3)
33
+ racc (1.7.1)
28
34
  rainbow (3.1.1)
29
35
  rake (13.0.6)
30
- regexp_parser (2.2.1)
31
- rexml (3.2.5)
32
- rubocop (1.25.1)
36
+ regexp_parser (2.8.1)
37
+ rexml (3.2.6)
38
+ rubocop (1.52.1)
39
+ json (~> 2.3)
33
40
  parallel (~> 1.10)
34
- parser (>= 3.1.0.0)
41
+ parser (>= 3.2.2.3)
35
42
  rainbow (>= 2.2.2, < 4.0)
36
43
  regexp_parser (>= 1.8, < 3.0)
37
- rexml
38
- rubocop-ast (>= 1.15.1, < 2.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.28.0, < 2.0)
39
46
  ruby-progressbar (~> 1.7)
40
- unicode-display_width (>= 1.4.0, < 3.0)
41
- rubocop-ast (1.16.0)
42
- parser (>= 3.1.1.0)
43
- rubocop-performance (1.13.2)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.29.0)
49
+ parser (>= 3.2.1.0)
50
+ rubocop-performance (1.18.0)
44
51
  rubocop (>= 1.7.0, < 2.0)
45
52
  rubocop-ast (>= 0.4.0)
46
- ruby-progressbar (1.11.0)
47
- sqlite3 (1.4.2)
48
- standard (1.7.2)
49
- rubocop (= 1.25.1)
50
- rubocop-performance (= 1.13.2)
51
- tzinfo (2.0.4)
53
+ ruby-progressbar (1.13.0)
54
+ sqlite3 (1.6.3-arm64-darwin)
55
+ sqlite3 (1.6.3-x86_64-linux)
56
+ standard (1.30.1)
57
+ language_server-protocol (~> 3.17.0.2)
58
+ lint_roller (~> 1.0)
59
+ rubocop (~> 1.52.0)
60
+ standard-custom (~> 1.0.0)
61
+ standard-performance (~> 1.1.0)
62
+ standard-custom (1.0.2)
63
+ lint_roller (~> 1.0)
64
+ rubocop (~> 1.50)
65
+ standard-performance (1.1.2)
66
+ lint_roller (~> 1.1)
67
+ rubocop-performance (~> 1.18.0)
68
+ tzinfo (2.0.6)
52
69
  concurrent-ruby (~> 1.0)
53
- unicode-display_width (2.1.0)
70
+ unicode-display_width (2.4.2)
54
71
 
55
72
  PLATFORMS
56
73
  arm64-darwin-21
57
74
  x86_64-linux
58
75
 
59
76
  DEPENDENCIES
60
- activerecord (= 7.0.3)
77
+ activerecord (= 7.0.7)
61
78
  activerecord-summarize!
62
79
  minitest (~> 5.0)
80
+ pg (~> 1.5)
63
81
  rake (~> 13.0)
64
- sqlite3 (= 1.4.2)
82
+ sqlite3 (= 1.6.3)
65
83
  standard (~> 1.3)
66
84
 
67
85
  BUNDLED WITH
data/README.md CHANGED
@@ -174,7 +174,9 @@ Instead the block is evaluated once to determine what calculations need to be ru
174
174
 
175
175
  ## Development
176
176
 
177
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
177
+ Run `bin/setup` to install dependencies. If you don't have PostgreSQL installed, comment out the `pg` line in `Gemfile` first. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
178
+
179
+ Tests and `bin/console` support SQLite and PostgreSQL: (un)comment the appropriate lines at the top of `test/test_data.rb` to choose. In the future, we'll have a nicer solution. If you want to use PostgreSQL, run `CREATE DATABASE summarize_test;` as your default user.
178
180
 
179
181
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
180
182
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Summarize
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
@@ -240,7 +240,10 @@ module ActiveRecord::Summarize
240
240
  end
241
241
 
242
242
  def value_selects
243
- @calculations.map { |f| f.select_value(@relation) }
243
+ @calculations.each_with_index.map do |f, i|
244
+ f.select_value(@relation)
245
+ .as("_v#{i}") # In Postgres with certain Rails versions, alias is needed to disambiguate result column names for type information
246
+ end
244
247
  end
245
248
 
246
249
  def lightly_touch_impure_hash(h)
@@ -88,12 +88,12 @@ class ChainableResult
88
88
  end
89
89
 
90
90
  def self.with(*results, &block)
91
- ChainableResult.wrap(results.size == 1 ? results.first : results, :then, &block)
91
+ ChainableResult.wrap((results.size == 1) ? results.first : results, :then, &block)
92
92
  end
93
93
 
94
94
  def self.sync_with(*results, &block)
95
95
  # Non-time-traveling, synchronous version of `with` for testing
96
- (results.size == 1 ? results.first : results).then(&block)
96
+ ((results.size == 1) ? results.first : results).then(&block)
97
97
  end
98
98
 
99
99
  # Shorter names are deprecated
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.5.0
4
+ version: 0.5.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: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord