fast_inserter 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: b47b07c052dd53d142036060330d279e244907df
4
- data.tar.gz: e3f2dc9ffc638988e26038a83de173e2d5dce660
3
+ metadata.gz: 11cad819cb2f00ec07b452cc3e85c3c20ce074de
4
+ data.tar.gz: 726d13fd3d3b64419a55bb9898e0629e985b6ca1
5
5
  SHA512:
6
- metadata.gz: 61b3456dcac8069daba1a29e5bf1330fcda71c87448fecb270b63fb213ebf841ab55cda70dfd5ccee81d800b263488cc33a7c06d83fb5fa0449fd2fd1d51a62a
7
- data.tar.gz: 93d44df482b6dc36fb072f042629612077e245eec7f2619a717fc258005330e98da5c085d96607d7371fd1a94383692d92b0d33a248bb168f11170d574c34d0d
6
+ metadata.gz: 3aa21e548ff8899ea7c63f665637072b3c3af3d4d68dc3a45bfb5af72bbb26a758098be11c84afbc9064ad30f185ed4970600545e52df0baca9fd753208212a8
7
+ data.tar.gz: 11ecd4447149a187c26bf356fb045292d91ce033a6b875ed5cf35a49cf4dc90d2305e306304067d9c9a07106274212a25c66d47ca95c616f10f47dd0cd9f7601
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ # RubyMine
12
+ .idea/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.1.2 (August 11, 2016) ##
2
+
3
+ * Added support for NULL static columns.
4
+
5
+ *Matt Hickman*
6
+
7
+
1
8
  ## 0.1.1 (February 11, 2016) ##
2
9
 
3
10
  * Add gem badge and changelog.
data/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/fast_inserter.svg)](https://badge.fury.io/rb/fast_inserter)
4
4
  [![Build Status](https://travis-ci.org/strydercorp/fast_inserter.svg?branch=master)](https://travis-ci.org/strydercorp/fast_inserter)
5
5
 
6
- Use raw SQL to insert database records in bulk. Supports uniqueness constraints, timestamps, and checking for existing records.
6
+ Use raw SQL to insert database records in bulk, fast. Supports uniqueness constraints, timestamps, and checking for existing records.
7
7
 
8
- The motivation for this library from the fact that rails does validations on each and every inserted record in the join table. And, even if you pass validate: false, it still loads each record and inserts one by one. This leads to very slow insertion of large number (thoasands) of records.
8
+ The motivation for this library comes from the fact that rails does validations on each and every inserted record in the join table. And, even if you pass validate: false, it still loads each record and inserts one by one. This is all good, but also means inserting a large number (thousands) of records is slow.
9
9
 
10
10
  This library skips active record altogether and uses raw sql to insert records. However, using raw sql goes around all your business logic, so we provide ways to still have niceties like uniqueness constraints and timestamps.
11
11
 
@@ -31,7 +31,9 @@ Or install it yourself as:
31
31
 
32
32
  ## Usage
33
33
 
34
- In most cases, you probably don't want to use this library and instead should active record. However, should you need to use this library, usage instructions are below.
34
+ *We wrote a longer post about this gem at https://joinhandshake.com/engineering/2016/01/26/quickly-inserting-thousands-of-records-in-rails.html*
35
+
36
+ In most cases, you probably don't want to use this library and instead should use active record. However, should you need to use this library, usage instructions are below.
35
37
 
36
38
  A basic usage for inserting multiple 'MassEmailsUser' records:
37
39
 
@@ -6,12 +6,12 @@ require 'fast_inserter/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fast_inserter"
8
8
  spec.version = FastInserter::VERSION
9
- spec.authors = ["Scott Ringwelski", "Brandon Gafford", "Jordon Dornbos"]
10
- spec.email = ["scott@joinhandshake.com", "brandon@joinhandshake.com", "jordon@joinhandshake.com"]
9
+ spec.authors = ["Scott Ringwelski", "Brandon Gafford", "Jordon Dornbos", "Matt Hickman"]
10
+ spec.email = ["scott@joinhandshake.com", "brandon@joinhandshake.com", "jordon@joinhandshake.com", "matt@joinhandshake.com"]
11
11
 
12
12
  spec.summary = %q{Quickly insert database records in bulk}
13
13
  spec.description = %q{Use raw SQL to insert database records in bulk. Supports uniqueness constraints, timestamps, and checking for existing records.}
14
- spec.homepage = "https://github.com/strydercorp/fast_inserter."
14
+ spec.homepage = "https://github.com/strydercorp/fast_inserter"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -110,8 +110,12 @@ module FastInserter
110
110
 
111
111
  def existing_values_static_columns
112
112
  @static_columns.map do |key, value|
113
- sanitized_value = ActiveRecord::Base.send(:sanitize_sql_array, ["?", value])
114
- "#{key} = #{sanitized_value}"
113
+ if value.nil?
114
+ "#{key} IS NULL"
115
+ else
116
+ sanitized_value = ActiveRecord::Base.send(:sanitize_sql_array, ["?", value])
117
+ "#{key} = #{sanitized_value}"
118
+ end
115
119
  end.join(' AND ')
116
120
  end
117
121
 
@@ -1,3 +1,3 @@
1
1
  module FastInserter
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_inserter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Ringwelski
8
8
  - Brandon Gafford
9
9
  - Jordon Dornbos
10
+ - Matt Hickman
10
11
  autorequire:
11
12
  bindir: exe
12
13
  cert_chain: []
13
- date: 2016-02-12 00:00:00.000000000 Z
14
+ date: 2016-08-11 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activerecord
@@ -102,6 +103,7 @@ email:
102
103
  - scott@joinhandshake.com
103
104
  - brandon@joinhandshake.com
104
105
  - jordon@joinhandshake.com
106
+ - matt@joinhandshake.com
105
107
  executables: []
106
108
  extensions: []
107
109
  extra_rdoc_files: []
@@ -122,7 +124,7 @@ files:
122
124
  - lib/fast_inserter.rb
123
125
  - lib/fast_inserter/fast_inserter_base.rb
124
126
  - lib/fast_inserter/version.rb
125
- homepage: https://github.com/strydercorp/fast_inserter.
127
+ homepage: https://github.com/strydercorp/fast_inserter
126
128
  licenses:
127
129
  - MIT
128
130
  metadata: {}