simple-sql 0.4.36 → 0.4.37

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: a8dc1ec7e4bb737434a4bcd95b612b9e100386bbc2896d67e09b68b6c7946172
4
- data.tar.gz: a3cfb7860e3c085514b4e294b7b99773cd2365292ca68e96bc81ede0c10fc8c7
3
+ metadata.gz: eb4ff06bf7f2aeba2ded053177b20b1db9630ee1f2534672e9bb5616a1d6ad93
4
+ data.tar.gz: 9ec867c270c8e4b263e61b0e222748d663021a40da6e650f2b072165e66eef21
5
5
  SHA512:
6
- metadata.gz: e3de0a9214dce2e7fc91de037fb58dc4beef47ee066acfdf366e2b6100f1a4592436078d13c34d34cbc102be25c5281b0177aace3b5c36be30dc0ed735e3438f
7
- data.tar.gz: fdb5081fae742c348157af72bcb119cc61ad88831f313fa640a64020ff6254c65ba1e662325bd684a92dda27c2d0f3bb40a7c0ef4dd8af82b3b7cdee0fdc59b9
6
+ metadata.gz: 4ecf49aa237ba87bb1cab4aa026eb3ce7dbaf123e0b161a0d9fd997e47aaf46bdba454a1f85f864ac8e85bd733ffd805fdc97df0d6981764ddb32642b5e24829
7
+ data.tar.gz: 8d54d93bcbfb5c06ce8be25264bf3b1f10cf0eb0039b60ea05350d0b2da23d1888d561ead99eddd984400b0cb3c6d48ada81f4bcc81a9ba6859c4a482383c904
@@ -35,17 +35,8 @@ class ::Simple::SQL::Result < Array
35
35
  # This is filled in when resolving a paginated scope.
36
36
  def total_count_estimate
37
37
  return @total_count_estimate if instance_variable_defined?(:@total_count_estimate)
38
-
39
- @total_count_estimate = if @pagination_scope
40
- catch(:total_count_estimate) do
41
- sql = @pagination_scope.order_by(nil).to_sql(pagination: false)
42
- ::Simple::SQL.each("EXPLAIN #{sql}", *@pagination_scope.args) do |line|
43
- next unless line =~ /\brows=(\d+)/
44
- throw :total_count_estimate, Integer($1)
45
- end
46
- -1
47
- end
48
- end
38
+
39
+ @total_count_estimate = _total_count_estimate
49
40
  end
50
41
 
51
42
  # returns the estimated total number of pages of search hits
@@ -53,7 +44,7 @@ class ::Simple::SQL::Result < Array
53
44
  # This is filled in when resolving a paginated scope.
54
45
  def total_pages_estimate
55
46
  return @total_pages_estimate if instance_variable_defined?(:@total_pages_estimate)
56
-
47
+
57
48
  @total_pages_estimate = (total_count_estimate * 1.0 / @pagination_scope.per).ceil if @pagination_scope
58
49
  end
59
50
 
@@ -63,10 +54,7 @@ class ::Simple::SQL::Result < Array
63
54
  def total_count
64
55
  return @total_count if instance_variable_defined?(:@total_count)
65
56
 
66
- @total_count = if @pagination_scope
67
- sql = @pagination_scope.order_by(nil).to_sql(pagination: false)
68
- ::Simple::SQL.ask("SELECT COUNT(*) FROM (#{sql}) _total_count", *@pagination_scope.args)
69
- end
57
+ @total_count = _total_count
70
58
  end
71
59
 
72
60
  # returns the total number of pages of search hits
@@ -104,4 +92,23 @@ class ::Simple::SQL::Result < Array
104
92
  @pagination_scope = scope
105
93
  end
106
94
  end
95
+
96
+ def _total_count_estimate
97
+ return unless @pagination_scope
98
+
99
+ sql = @pagination_scope.order_by(nil).to_sql(pagination: false)
100
+ ::Simple::SQL.each("EXPLAIN #{sql}", *@pagination_scope.args) do |line|
101
+ next unless line =~ /\brows=(\d+)/
102
+ return Integer($1)
103
+ end
104
+
105
+ -1
106
+ end
107
+
108
+ def _total_count
109
+ return unless @pagination_scope
110
+
111
+ sql = @pagination_scope.order_by(nil).to_sql(pagination: false)
112
+ ::Simple::SQL.ask("SELECT COUNT(*) FROM (#{sql}) _total_count", *@pagination_scope.args)
113
+ end
107
114
  end
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module SQL
3
- VERSION = "0.4.36"
3
+ VERSION = "0.4.37"
4
4
  end
5
5
  end
data/lib/simple/sql.rb CHANGED
@@ -35,6 +35,11 @@ module Simple
35
35
  Connection.create(database_url)
36
36
  end
37
37
 
38
+ # deprecated
39
+ def configuration
40
+ Config.parse_url(Config.determine_url)
41
+ end
42
+
38
43
  # -- default connection ---------------------------------------------------
39
44
 
40
45
  DEFAULT_CONNECTION_KEY = :"Simple::SQL.default_connection"
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.4.36
4
+ version: 0.4.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel