activerecord_upsert 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +17 -6
- data/.travis/gemfiles/Gemfile-no-cpk +4 -0
- data/CHANGELOG.md +4 -1
- data/Gemfile +2 -0
- data/README.md +3 -0
- data/lib/active_record_upsert/active_record/persistence.rb +6 -1
- data/lib/active_record_upsert/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cbd25aa6318ec5dd56d94342b23f35bb888de2e08a9ad775f3e36ec672a804b
|
4
|
+
data.tar.gz: b19435c408f5ba2022b5a1e992cafb7920196e3705ccbcbf71f0a616699fcb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c136d6f7f5ca22d8d6d7ff98ae4a513b01e53c8b9b8323af6d6ab8013631e7334be5bba390547bf2efbcb8c60745e092a4eec933af5b3cfd34bfde08b1e16b4d
|
7
|
+
data.tar.gz: 13839119ff4f61e426650cd1c4f25d892bdb852741a6b5cdbcb2f1a2743766be870b5aca4e7b4ab48daaa608b02003981459e9ddbcef46c76692bf1d764339c2
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
services:
|
4
|
+
- mysql
|
3
5
|
cache:
|
4
6
|
- bundler
|
7
|
+
env:
|
8
|
+
- MYSQL_USERNAME=root MYSQL_PASSWORD=
|
5
9
|
rvm:
|
6
|
-
- 2.2.9
|
7
10
|
- 2.3.8
|
8
|
-
- 2.4.
|
9
|
-
- 2.5.
|
10
|
-
- 2.6.
|
11
|
-
- 2.7.0.
|
11
|
+
- 2.4.9
|
12
|
+
- 2.5.7
|
13
|
+
- 2.6.5
|
14
|
+
- 2.7.0.preview3
|
15
|
+
gemfile:
|
16
|
+
- Gemfile
|
17
|
+
- .travis/gemfiles/Gemfile-no-cpk
|
18
|
+
before_install:
|
19
|
+
- gem install bundler -v 2.0.2
|
20
|
+
- mysql -e 'CREATE DATABASE active_record_upsert_test;'
|
12
21
|
matrix:
|
13
22
|
allow_failures:
|
14
|
-
- rvm: 2.7.0.
|
23
|
+
- rvm: 2.7.0.preview3
|
24
|
+
|
25
|
+
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# ActiveRecord Upsert
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/dvandersluis/activerecord_upsert.svg?branch=master)](https://travis-ci.org/dvandersluis/activerecord_upsert)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/activerecord_upsert.svg)](https://badge.fury.io/rb/activerecord_upsert)
|
5
|
+
|
3
6
|
Adds the ability to use MySQL's `ON DUPLICATE KEY UPDATE` to upsert records in ActiveRecord.
|
4
7
|
|
5
8
|
**Note**: This will conflict with Rails 6, which adds its own upsert, so requires Rails 5.2 currently.
|
@@ -3,7 +3,7 @@ module ActiveRecordUpsert
|
|
3
3
|
module Persistence
|
4
4
|
def _upsert_record(values, on_duplicate)
|
5
5
|
set_timestamps(values)
|
6
|
-
set_primary_key_value(values)
|
6
|
+
set_primary_key_value(values) unless composite?
|
7
7
|
|
8
8
|
im = compile_insert(values, on_duplicate)
|
9
9
|
connection.insert(im, "#{self} Upsert", primary_key || false, values[primary_key])
|
@@ -41,6 +41,11 @@ module ActiveRecordUpsert
|
|
41
41
|
im.on_duplicate_update(on_duplicate)
|
42
42
|
im
|
43
43
|
end
|
44
|
+
|
45
|
+
def composite?
|
46
|
+
return false unless defined?(super)
|
47
|
+
super
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_upsert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vandersluis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- ".rspec"
|
168
168
|
- ".rubocop.yml"
|
169
169
|
- ".travis.yml"
|
170
|
+
- ".travis/gemfiles/Gemfile-no-cpk"
|
170
171
|
- CHANGELOG.md
|
171
172
|
- Gemfile
|
172
173
|
- README.md
|
@@ -202,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
203
|
- !ruby/object:Gem::Version
|
203
204
|
version: '0'
|
204
205
|
requirements: []
|
205
|
-
rubygems_version: 3.0.
|
206
|
+
rubygems_version: 3.0.6
|
206
207
|
signing_key:
|
207
208
|
specification_version: 4
|
208
209
|
summary: Support MySQL's INSERT ... ON DUPLICATE KEY UPDATE in ActiveRecord
|