fast_inserter 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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/fast_inserter/fast_inserter_base.rb +7 -3
- data/lib/fast_inserter/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: c9a5654ca484c5f0b47bfa91c6f5e1bb52549933
|
4
|
+
data.tar.gz: 9d239e735b0333d3662dc663e5fb5dfb83a6bee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c89ce208dc7b8bcfb95b4bdb8e632b8712cc47bb7348f0f88d67ec83ccf986b69d565b8f66fc880f629ae12f909b13d89beeae960c431e3ab77f1a4f67486c5
|
7
|
+
data.tar.gz: a65992d6071b696bbc25b523002fcb5a32d84d4b0733f07f4a91c52cc4eef96f49947225bdf0431c1443d2a738eb36375dec7b29d2981cb9ee1b95eeea550e40
|
data/CHANGELOG.md
CHANGED
@@ -94,20 +94,24 @@ module FastInserter
|
|
94
94
|
|
95
95
|
# Queries for the existing values for a given group of values
|
96
96
|
def existing_values(group_of_values)
|
97
|
-
|
98
|
-
sql = "SELECT #{@variable_column} FROM #{@table_name} WHERE #{existing_values_static_columns} AND #{@variable_column} IN (#{values_to_check})"
|
97
|
+
sql = "SELECT #{@variable_column} FROM #{@table_name} WHERE #{existing_values_static_columns}"
|
99
98
|
|
100
99
|
# NOTE: There are more elegant ways to get this field out of the resultset, but each database adaptor returns a different type
|
101
100
|
# of result from 'execute(sql)'. Potential classes for 'result' is Array (sqlite), Mysql2::Result (mysql2), PG::Result (pg). Each
|
102
101
|
# result can be enumerated into a list of arrays (mysql) or list of hashes (sqlite, pg)
|
103
102
|
results = ActiveRecord::Base.connection.execute(sql)
|
104
|
-
results.to_a.map do |result|
|
103
|
+
existing_values = results.to_a.map do |result|
|
105
104
|
if result.is_a?(Hash)
|
106
105
|
result[@variable_column].to_s
|
107
106
|
elsif result.is_a?(Array)
|
108
107
|
result[0].to_s
|
109
108
|
end
|
110
109
|
end
|
110
|
+
|
111
|
+
# Rather than a giant IN query in the sql statement (which can be bad for database performance),
|
112
|
+
# do the filtering of relevant values here in a ruby select.
|
113
|
+
group_of_values_strings = group_of_values.map(&:to_s)
|
114
|
+
existing_values & group_of_values_strings
|
111
115
|
end
|
112
116
|
|
113
117
|
def existing_values_static_columns
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_inserter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|