active_record_temptable 0.1.3 → 0.1.4

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: '0796a93f67d07ac14c2c9081f028ed353ffa7d8862369c75c754afabe24aa4c1'
4
- data.tar.gz: 63e539ad205e9e95a09878e9c60f7869b54d7575d2156873867bdb1f194fd736
3
+ metadata.gz: 2a7c686e6c4732aa2ed0372acb25adc642f2d454c9cc0df3433a81ea5b352293
4
+ data.tar.gz: 3b6ac5aa2a1e820d24d41eb6c331262aa51d024a2909037b27a48b50b9fa7618
5
5
  SHA512:
6
- metadata.gz: d94a7d573a5c277d4642ad3e4c3f078c28b92d77ffcead4e6374a6703b6d3f6bc23212083d451fce2a84cabee200b50771b6bb65e0dfeab049575bcdc242c56a
7
- data.tar.gz: 797aca6dde9fb5486fc86c37224db33fa16de5046367f7041ede5da3bfe3a1764a9eaa68d79aeb08ba014bd666d86378b99c371da32f4313db8cfac7a06158df
6
+ metadata.gz: 78f2f76fc2df5fceb415f150e6aca8e67159c13c8d11976a8034bb91e8b38ca8944e047f19f378c9f9bfb1588f4ed0ac6e5ae88e8e089f062564481187dfcd6a
7
+ data.tar.gz: 202cef478c39d7e7239bb880ec821a6f50eab951ad792dc24acee6d3118d99636a15e4acfefc4991e269bcb136593360bf7554f1d40e9ffd5854388bfe619bdf
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record_temptable (0.1.3)
4
+ active_record_temptable (0.1.4)
5
5
  activerecord (>= 4.2.3)
6
6
 
7
7
  GEM
@@ -19,8 +19,8 @@ module ActiveRecordTemptable
19
19
  ActiveRecord::Base.connection_pool.with_connection do |connection|
20
20
  connection.transaction do
21
21
  begin
22
- create_table(connection, relation, table_name)
23
- create_indexes(connection, table_name, indexes) if indexes.any?
22
+ connection.create_table(table_name, temporary: true, as: relation.to_sql)
23
+ create_indexes(connection, table_name, indexes)
24
24
  klass = relation.klass
25
25
  yield klass.unscoped.from("#{table_name} AS #{klass.table_name}") if block_given?
26
26
  ensure
@@ -30,16 +30,6 @@ module ActiveRecordTemptable
30
30
  end
31
31
  end
32
32
 
33
- # Creates temp table and loads provided relation into it
34
- #
35
- # @param connection [ActiveRecord::ConnectionAdapters]
36
- # @param relation [ActiveRecord::Relation]
37
- # @param table_name [String] name of table
38
- # @return [void]
39
- def create_table(connection, relation, table_name)
40
- connection.execute(new_table_command(relation, table_name))
41
- end
42
-
43
33
  # Calls add_index for every element in array
44
34
  #
45
35
  # @param connection [ActiveRecord::ConnectionAdapters]
@@ -51,10 +41,4 @@ module ActiveRecordTemptable
51
41
  connection.add_index(table_name, fields, options || {})
52
42
  end
53
43
  end
54
-
55
- private
56
-
57
- def new_table_command(relation, table_name)
58
- "CREATE TEMPORARY TABLE #{table_name} AS #{relation.to_sql}"
59
- end
60
44
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordTemptable
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_temptable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Henryk Bartkowiak