simple-sql 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ describe "Simple::SQL::Connection::Scope#count_by" do
24
24
  end
25
25
  end
26
26
 
27
- describe "fast_count_by" do
27
+ describe "count_by_estimate" do
28
28
  before do
29
29
  # 10_000 is chosen "magically". It is large enough to switch to the fast algorithm,
30
30
  # but
@@ -36,9 +36,9 @@ describe "Simple::SQL::Connection::Scope#count_by" do
36
36
  create(:user, role_id: 1)
37
37
  create(:user, role_id: 1)
38
38
 
39
- expect(scope.fast_count_by("role_id")).to include(1 => 4)
40
- expect(scope.fast_count_by("role_id")).to include(2 => 1)
41
- expect(scope.fast_count_by("role_id").keys).to contain_exactly(*all_role_ids)
39
+ expect(scope.count_by_estimate("role_id")).to include(1 => 4)
40
+ expect(scope.count_by_estimate("role_id")).to include(2 => 1)
41
+ expect(scope.count_by_estimate("role_id").keys).to contain_exactly(*all_role_ids)
42
42
  end
43
43
  end
44
44
  end
@@ -18,12 +18,12 @@ describe "Simple::SQL::Connection::Scope#count" do
18
18
 
19
19
  describe "fast count" do
20
20
  it "counts" do
21
- expect(scope.fast_count).to eq(USER_COUNT)
21
+ expect(scope.count_estimate).to eq(USER_COUNT)
22
22
  end
23
23
 
24
24
  it "evaluates conditions" do
25
- expect(scope.where("id < $1", min_user_id).fast_count).to eq(0)
26
- expect(scope.where("id <= $1", min_user_id).fast_count).to eq(1)
25
+ expect(scope.where("id < $1", min_user_id).count_estimate).to eq(0)
26
+ expect(scope.where("id <= $1", min_user_id).count_estimate).to eq(1)
27
27
  end
28
28
  end
29
29
  end
@@ -10,7 +10,6 @@ describe "Simple::SQL::Result counts" do
10
10
  it "counts" do
11
11
  result = SQL.all(paginated_scope)
12
12
  expect(result.total_count).to eq(USER_COUNT)
13
- expect(result.total_pages).to eq(USER_COUNT)
14
13
  expect(result.current_page).to eq(1)
15
14
  end
16
15
  end
@@ -19,8 +18,7 @@ describe "Simple::SQL::Result counts" do
19
18
  it "counts fast" do
20
19
  result = SQL.all(paginated_scope)
21
20
 
22
- expect(result.total_fast_count).to eq(USER_COUNT)
23
- expect(result.total_fast_pages).to eq(USER_COUNT)
21
+ expect(result.total_count_estimate).to eq(USER_COUNT)
24
22
  expect(result.current_page).to eq(1)
25
23
  end
26
24
  end
@@ -30,10 +28,8 @@ describe "Simple::SQL::Result counts" do
30
28
  result = SQL.all(scope)
31
29
 
32
30
  expect { result.total_count }.to raise_error(RuntimeError)
33
- expect { result.total_pages }.to raise_error(RuntimeError)
34
31
  expect { result.current_page }.to raise_error(RuntimeError)
35
- expect { result.total_fast_count }.to raise_error(RuntimeError)
36
- expect { result.total_fast_pages }.to raise_error(RuntimeError)
32
+ expect { result.total_count_estimate }.to raise_error(RuntimeError)
37
33
  end
38
34
  end
39
35
 
@@ -46,11 +42,7 @@ describe "Simple::SQL::Result counts" do
46
42
  result = SQL.all(paginated_scope)
47
43
 
48
44
  expect(result.total_count).to eq(0)
49
- expect(result.total_pages).to eq(1)
50
-
51
- expect(result.total_fast_count).to eq(0)
52
- expect(result.total_fast_pages).to eq(1)
53
-
45
+ expect(result.total_count_estimate).to eq(0)
54
46
  expect(result.current_page).to eq(1)
55
47
  end
56
48
  end
@@ -235,7 +235,6 @@ describe "Simple::SQL::Connection::Scope" do
235
235
  result = SQL.all(scope.paginate(per: 1, page: 1))
236
236
 
237
237
  expect(result).to eq([[1, 2]])
238
- expect(result.total_pages).to eq(2)
239
238
  expect(result.current_page).to eq(1)
240
239
  expect(result.total_count).to eq(2)
241
240
  end
@@ -246,7 +245,6 @@ describe "Simple::SQL::Connection::Scope" do
246
245
  result = SQL.all(scope.paginate(per: 2, page: 2))
247
246
 
248
247
  expect(result).to eq([])
249
- expect(result.total_pages).to eq(1)
250
248
  expect(result.current_page).to eq(2)
251
249
  expect(result.total_count).to eq(2)
252
250
  end
@@ -255,7 +253,6 @@ describe "Simple::SQL::Connection::Scope" do
255
253
  result = SQL.all(scope.paginate(per: 2, page: 1))
256
254
 
257
255
  expect(result).to eq([[1, 2], [1, 2]])
258
- expect(result.total_pages).to eq(1)
259
256
  expect(result.current_page).to eq(1)
260
257
  expect(result.total_count).to eq(2)
261
258
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-03 00:00:00.000000000 Z
12
+ date: 2019-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg_array_parser
@@ -193,6 +193,7 @@ files:
193
193
  - README.md
194
194
  - Rakefile
195
195
  - bin/console
196
+ - bin/db_restore
196
197
  - bin/pg
197
198
  - bin/rake
198
199
  - config/console-init.rb
@@ -231,6 +232,7 @@ files:
231
232
  - scripts/stats
232
233
  - scripts/watch
233
234
  - simple-sql.gemspec
235
+ - spec/fixtures/booktown.sql
234
236
  - spec/manual/threadtest.rb
235
237
  - spec/simple/sql/all_into_spec.rb
236
238
  - spec/simple/sql/ask_spec.rb
@@ -281,6 +283,7 @@ signing_key:
281
283
  specification_version: 4
282
284
  summary: SQL with a simple interface
283
285
  test_files:
286
+ - spec/fixtures/booktown.sql
284
287
  - spec/manual/threadtest.rb
285
288
  - spec/simple/sql/all_into_spec.rb
286
289
  - spec/simple/sql/ask_spec.rb