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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8573e5d5eb0642aee3a01d2c5cb0dbfc4a953282e5600c567fb4f26bffc38470
4
- data.tar.gz: a380f11680573b7dd735f838f85037577c85238fc1c66b02487659daae537be1
3
+ metadata.gz: 8cbd25aa6318ec5dd56d94342b23f35bb888de2e08a9ad775f3e36ec672a804b
4
+ data.tar.gz: b19435c408f5ba2022b5a1e992cafb7920196e3705ccbcbf71f0a616699fcb11
5
5
  SHA512:
6
- metadata.gz: 9df3b5e9e725e8e0cda714511180b0858ce090e4b0e98a72e8f9d30f9df2de691750ec1961c17c079f4cc07c4dbb8021ef98e50886fd3e9caa93335b64ba5c79
7
- data.tar.gz: 98cc6703921f84910452be1731db7328b9c70aaea49dce6cd9b3922015c59c06aa772f8bd91973b98488d30108fc03b748ee4e8be23a19358a03a87fc1002044
6
+ metadata.gz: c136d6f7f5ca22d8d6d7ff98ae4a513b01e53c8b9b8323af6d6ab8013631e7334be5bba390547bf2efbcb8c60745e092a4eec933af5b3cfd34bfde08b1e16b4d
7
+ data.tar.gz: 13839119ff4f61e426650cd1c4f25d892bdb852741a6b5cdbcb2f1a2743766be870b5aca4e7b4ab48daaa608b02003981459e9ddbcef46c76692bf1d764339c2
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ Gemfile.lock
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.6
9
- - 2.5.5
10
- - 2.6.3
11
- - 2.7.0.preview2
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.preview1
23
+ - rvm: 2.7.0.preview3
24
+
25
+
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activerecord_upsert.gemspec
4
+ gemspec path: '../..'
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG
2
2
 
3
- ## v0.1.0
3
+ ## v0.2.0 (December 16, 2019)
4
+ - Added compatibility with `composite_primary_keys` gem.
5
+
6
+ ## v0.1.0 (October 29, 2019)
4
7
  - Initial version
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in activerecord_upsert.gemspec
4
4
  gemspec
5
+
6
+ gem 'composite_primary_keys', '~> 11.2'
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
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordUpsert
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  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.1.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-10-29 00:00:00.000000000 Z
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.3
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