effective_datatables 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/datatable.rb +16 -7
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33500ce573ca5338516e3e79dfb3c06c44dc81d
|
4
|
+
data.tar.gz: 6aa75a77d9bf1151deb0cfc71935086f2cb75fdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de12751ecd5de42f4404d52e90ff3666e1ecff389d8f6acc2e3c108a8e4493a923a9025ce192c0e86e99f72e75cbf68180b06d76fbeef925e901f336aa3838a
|
7
|
+
data.tar.gz: 41f47e6044204bc970b0660b7a583d5a46e17ac9725465ef763ffbe711c1580f108d24d509812c774836527f4bf8c03acb99a65502af6fb50fa5e0403a5f648d
|
@@ -68,17 +68,16 @@ module Effective
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
71
|
def initialize(*args)
|
73
|
-
unless active_record_collection? || (collection.kind_of?(Array) && collection.first.kind_of?(Array))
|
74
|
-
raise "Unsupported collection type. Should be ActiveRecord class, ActiveRecord relation, or an Array of Arrays [[1, 'something'], [2, 'something else']]"
|
75
|
-
end
|
76
|
-
|
77
72
|
if args.present?
|
78
73
|
raise 'Effective::Datatable.new() can only be called with a Hash like arguments' unless args.first.kind_of?(Hash)
|
79
74
|
args.first.each { |k, v| self.attributes[k] = v }
|
80
75
|
end
|
81
76
|
|
77
|
+
unless active_record_collection? || (collection.kind_of?(Array) && collection.first.kind_of?(Array))
|
78
|
+
raise "Unsupported collection type. Should be ActiveRecord class, ActiveRecord relation, or an Array of Arrays [[1, 'something'], [2, 'something else']]"
|
79
|
+
end
|
80
|
+
|
82
81
|
# Any pre-selected search terms should be assigned now
|
83
82
|
search_terms.each { |column, term| self.send("#{column}=", term) }
|
84
83
|
end
|
@@ -235,7 +234,11 @@ module Effective
|
|
235
234
|
|
236
235
|
def total_records
|
237
236
|
@total_records ||= (
|
238
|
-
if active_record_collection?
|
237
|
+
if active_record_collection? && collection_class.connection.respond_to?(:unprepared_statement)
|
238
|
+
# https://github.com/rails/rails/issues/15331
|
239
|
+
collection_sql = collection_class.connection.unprepared_statement { collection.to_sql }
|
240
|
+
(collection_class.connection.execute("SELECT COUNT(*) FROM (#{collection_sql}) AS datatables_total_count").first['count'] rescue 1).to_i
|
241
|
+
elsif active_record_collection?
|
239
242
|
(collection_class.connection.execute("SELECT COUNT(*) FROM (#{collection.to_sql}) AS datatables_total_count").first['count'] rescue 1).to_i
|
240
243
|
else
|
241
244
|
collection.size
|
@@ -278,7 +281,13 @@ module Effective
|
|
278
281
|
col = table_tool.search(col)
|
279
282
|
|
280
283
|
if table_tool.search_terms.present? && array_tool.search_terms.blank?
|
281
|
-
|
284
|
+
if collection_class.connection.respond_to?(:unprepared_statement)
|
285
|
+
# https://github.com/rails/rails/issues/15331
|
286
|
+
col_sql = collection_class.connection.unprepared_statement { col.to_sql }
|
287
|
+
self.display_records = (collection_class.connection.execute("SELECT COUNT(*) FROM (#{col_sql}) AS datatables_filtered_count").first['count'] rescue 1).to_i
|
288
|
+
else
|
289
|
+
self.display_records = (collection_class.connection.execute("SELECT COUNT(*) FROM (#{col.to_sql}) AS datatables_filtered_count").first['count'] rescue 1).to_i
|
290
|
+
end
|
282
291
|
end
|
283
292
|
end
|
284
293
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|